1
Fork 0
mirror of https://github.com/RGBCube/JsonWrapper synced 2025-07-27 11:47:45 +00:00

Update README.md

This commit is contained in:
RGBCube 2022-01-12 21:52:04 +03:00 committed by GitHub
parent 5f5e1cf802
commit c22c2a77dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,16 +17,20 @@ Deletes everything in the JSON.
Use with caution. Use with caution.
# Usage # Usage
Code:
```python ```python
from db import ClutterDB from db import ClutterDB
# initialization # initialization
db = ClutterDB("path/to/json/file.json") db = ClutterDB("path/to/json/file.json")
# defining a variable # defining the "a" variable
# (this will overrride the previous a if it was defined before) # (this will overrride the previous "a" if it was defined before)
db.set("a", 12345) db.set("a", 12345)
# another one for demonstration purposes
db.set("b", 123456)
# getting a variable # getting a variable
# (default kwarg will be returned if the key was not defined in the json) # (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") 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 # prints data
print(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") db.rem("a")
# nukes the json # nukes the json
db.nuke() db.nuke()
``` ```
Output:
```
12345
{'a': 12345, 'b': 123456}
```