1
Fork 0
mirror of https://github.com/RGBCube/JsonWrapper synced 2025-07-27 19:57:44 +00:00

Update README.md

This commit is contained in:
RGBCube 2022-01-16 10:36:11 +03:00 committed by GitHub
parent 2894fc59e9
commit 0691d234dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,8 +11,10 @@ Add `from db import CluttterDB` to the top of your project.
Sets the key to the value in the JSON. Sets the key to the value in the JSON.
if the `pathmagic` kwarg is given, it will spit it by the `+`'s and make dicts(or use existing ones) until it finishes, then it will set the value to the key in the last dict. if the `pathmagic` kwarg is given, it will spit it by the `+`'s and make dicts(or use existing ones) until it finishes, then it will set the value to the key in the last dict.
## `db.get(key: str, *, default=None)` ## `db.get(key: str, *, default=None, pathmagic="")`
Returns the value of the key in the json, if the key isn't set in the json, it returns the default kwarg. Returns the value of the key in the json, if the key isn't set in the json, it returns the default kwarg.
if the `pathmagic` kwarg is given, it will spit it by the `+`'s and follow the path in it in the JSON data, will return the `default` kwarg if the path is empty or has a value that isnt a dict.
## `db.all()` ## `db.all()`
Returns all the JSON data. Returns all the JSON data.
## `db.rem(key: str)` ## `db.rem(key: str)`
@ -102,6 +104,23 @@ db = ClutterDB("db.json")
data = db.get("test", default=123) data = db.get("test", default=123)
print(data)
```
Output
```
123
```
### Using with `pathmagic` kwarg
Code
```python
from db import ClutterDB
db = ClutterDB("db.json")
db.set("test", 123, pathmagic="a+b+c")
data = db.get("test", pathmagic="a+b+c")
print(data) print(data)
``` ```
Output Output