mirror of
https://github.com/RGBCube/JsonWrapper
synced 2025-07-27 11:47:45 +00:00
Update README.md
This commit is contained in:
parent
5f5e1cf802
commit
c22c2a77dd
1 changed files with 18 additions and 3 deletions
21
README.md
21
README.md
|
@ -17,16 +17,20 @@ Deletes everything in the JSON.
|
|||
|
||||
Use with caution.
|
||||
# Usage
|
||||
Code:
|
||||
```python
|
||||
from db import ClutterDB
|
||||
|
||||
# initialization
|
||||
db = ClutterDB("path/to/json/file.json")
|
||||
|
||||
# defining a variable
|
||||
# (this will overrride the previous a if it was defined before)
|
||||
# defining the "a" variable
|
||||
# (this will overrride the previous "a" if it was defined before)
|
||||
db.set("a", 12345)
|
||||
|
||||
# another one for demonstration purposes
|
||||
db.set("b", 123456)
|
||||
|
||||
# getting a variable
|
||||
# (default kwarg will be returned if the key was not defined in the json)
|
||||
data = db.get("a", default="a was not defined in the json")
|
||||
|
@ -34,9 +38,20 @@ data = db.get("a", default="a was not defined in the json")
|
|||
# prints data
|
||||
print(data)
|
||||
|
||||
# removes the a from the json
|
||||
# gets all json data
|
||||
data = db.all()
|
||||
|
||||
# prints data
|
||||
print(data)
|
||||
|
||||
# removes the "a" from the json
|
||||
db.rem("a")
|
||||
|
||||
# nukes the json
|
||||
db.nuke()
|
||||
```
|
||||
Output:
|
||||
```
|
||||
12345
|
||||
{'a': 12345, 'b': 123456}
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue