https://github.com/krypton-byte/dict2object
https://github.com/krypton-byte/dict2object
dictionary javascript json object python
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/krypton-byte/dict2object
- Owner: krypton-byte
- Created: 2021-07-12T11:49:51.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-18T11:06:57.000Z (about 2 years ago)
- Last Synced: 2025-02-26T05:06:53.447Z (over 1 year ago)
- Topics: dictionary, javascript, json, object, python
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Install
```bash
$ pip install git+https://github.com/krypton-byte/dict2object
```
### Convert Dict Datatype to Javascript Object Like
```python
>>> from dict2object import JSObject
>>> js=JSObject(indent=' '*4).fromDict({
'a':3,
'1':10,
'add':(lambda a, b: a.__add__(b))
})
>>> js
{
add: at 0x7f9b5f4bd1b0>,
'1': 10,
a: 3
}
>>> js.add(9, 11)
20
>>> js.add(js['1'], js.a)
13
```