Skip to main content

Simple JSON Lib

Project description

JsonSimple

JsonSimple demo:

from JsonSimple import JsonSimple


js = JsonSimple('{"code":0,"data":{"total":2,"list":[{"id":1,"name":"zhang_san","0":"a"},{"id":2,"name":"li"}]}}')
data = js.data.list._0.__0  # noqa
print(data)
# a
data = js.data.list._0.name  # noqa
print(data)
# zhang_san
data = js.get_value('data.list.0.0')
print(data)
# a

js.set_value('data.list.0.50', '5455555')
print(js)
# {"code": 0, "data": {"total": 2, "list": [{"id": 1, "name": "zhang_san", "0": "a", "50": "5455555"}, {"id": 2, "name": "li"}]}}
js.set_value('data.list.0.new_field.name', 'new_name')
print(js)
# {"code": 0, "data": {"total": 2, "list": [{"id": 1, "name": "zhang_san", "0": "a", "50": "5455555", "new_field": {"name": "new_name"}}, {"id": 2, "name": "li"}]}}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

JsonSimple-0.0.0.3.tar.gz (2.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page