Skip to content

Latest commit

 

History

History
executable file
·
44 lines (29 loc) · 854 Bytes

README.rst

File metadata and controls

executable file
·
44 lines (29 loc) · 854 Bytes

JSONv

A toy project to help learn ANTLR. JSONv is an extension to the JSON syntax which supports 'variables'.

JSONv makes it easy to template JSON files ensuring correct syntax and preserving non-string types.

Example

{
  "hello": [foo, bar],
  "world": {
    "config": variable_dictionary,
    "something": [0, 1, "string literal", variable]
  }
}

Python API

from jsonv import jsonv

jv = jsonv.loads('{"hello": [foo, bar]}')

assert not jv.bound
assert isinstance(jv, dict)
assert 'hello' in jv

jv.bind({'foo': 'world', 'bar': {'a nested': 'dictionary'}})
assert jv.bound

assert jsonv.dumps(jv) == '{"hello": ["world", {"a nested": "dictionary"}]}'

Installing

pip install .