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
2894fc59e9
commit
0691d234dd
1 changed files with 20 additions and 1 deletions
21
README.md
21
README.md
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue