Development Documents¶
The jsondata paclkage provides for the structure operations on JSON data.
Concepts and Design¶
- Software design
- JSON Data : Manage branches of substructures - jsondata.jsondata [features] [API] [source]
- JSON Serializer : Serialize JSON documents - jsondata.jsondataserializer [features] [API] [source]
- JSON Pointer : Access pointer paths and values - jsondata.jsonpointer [features] [API] [source]
- JSON Patch : Modify data structures and values - jsondata.jsonpatch [features] [API] [source]
- Integration with Standard Libraries
API¶
Examples¶
- HowTo - Typical call examples
- Selected Common UsesCases [examples]
- Test data [testdata]
jsondata¶
| [docs] | [source] |
|---|---|
| jsondata module | jsondata.__init__ (0) |
jsondata.jsondata¶
JSONData¶
Provides operations modes in accordance to RFC7159 [RFC7159] and RFC4627 [RFC4627].
Attributes¶
The slim wrapper only around the attributes of native data structures:
- JSONData.data - a reference to the in-memory JSON data, compatible to json [json] and ujson [ujson].
- JSONData.schema - a reference to an optional schema based on jsonschema [jsonschema].
Methods¶
Basic¶
| [docs] | [source] | [op-unit-scope] |
|---|---|---|
| JSONData() | JSONData.__init__ | |
| __repr__ | JSONData.__repr__ | B,A |
| __str__ | JSONData.__str__ | B,A |
| get_data | JSONData.get_data | |
| get_schema | JSONData.get_schema | |
| dump_data | JSONData.dump_data | A |
| dump_schema | JSONData.dump_schema | |
| set_schema | JSONData.set_schema | |
| validate | JSONData.validate | B,A |
The column [op-unit-scope] depicts the types and levels of provided operations:
- A: attribute
- B: branch
Branches and Trees¶
| [docs] | [source] | [op-unit-scope] | [equivalet-operator] |
|---|---|---|---|
| branch_add | JSONData.branch_add | B | add |
| branch_copy | JSONData.branch_copy | B | cp |
| branch_create | JSONData.branch_create | B | new |
| branch_move | JSONData.branch_move | B | mv |
| branch_remove | JSONData.branch_remove | B | del |
| branch_replace | JSONData.branch_replace | B | replace |
| branch_superpose | JSONData.branch_superpose | B | all-ops |
| branch_test | JSONData.branch_test | B | test |
| copy | JSONData.copy | B | cp |
| deepcopy | JSONData.deepcopy | B | cp |
| get_canonical_value | JSONData.get_canonical_value | B | |
| pop | JSONData.pop | pop |
Operators¶
Evaluation Operators¶
| [logic-operator] | [docs] | [source] | [op-unit-scope] |
|---|---|---|---|
| exec | __call__ | JSONData.__call__ | A |
Comparison Operators¶
| [logic-operator] | [docs] | [source] | [op-unit-scope] |
|---|---|---|---|
| == | __eq__ | JSONData.__eq__ | B,A |
| != | __ne__ | JSONData.__ne__ | B,A |
Items¶
| [operator] | [docs] | [source] | [op-unit-scope] |
|---|---|---|---|
| del S[x] | __delitem__ | JSONData.__delitem__ | B,A |
| __iter__ | __iter__ | JSONData.__iter__ | B,A |
| S[x] | __getitem__ | JSONData.__getitem__ | B,A |
| S[x] = v | __setitem__ | JSONData.__setitem__ | B,A |
| get_data_items | get_data_items | JSONData.get_data_items | B,A |
jsondata.jsondataserializer¶
JSONDataSerializer¶
Is derived from JSONData, provides persistency and schema validation.
Methods¶
Basic¶
| [docs] | [source] |
|---|---|
| JSONDataSerializer | JSONDataSerializer.__init__ |
| dump_data | JSONDataSerializer.dump_data |
| dump_schema | JSONDataSerializer.dump_schema |
| set_schema (1) | JSONDataSerializer.set_schema |
Import/Export¶
| [docs] | [source] |
|---|---|
| json_export | JSONDataSerializer.json_export |
| json_import | JSONDataSerializer.json_import |
jsondata.jsonpatch¶
Supports RFC6902 [RFC6902].
JSONPatchItem¶
Methods¶
Basic¶
| [docs] | [source] | [logic-operator] |
|---|---|---|
| JSONPatchItem | JSONPatchItem.__init__ | |
| __repr__ (2) | JSONPatchItem.__repr__ | repr |
| __str__ (2) | JSONPatchItem.__str__ | str |
Basic¶
| [docs] | [source] | [logic-operator] |
|---|---|---|
| apply (2) | JSONPatchItem.apply | |
| repr_export (2) | JSONPatchItem.repr_export | |
| str_export (2) | JSONPatchItem.str_export |
Operators¶
| [docs] | [source] | [logic-operator] |
|---|---|---|
| __call__ (2) | JSONPatchItem.__call__ | exec |
| __eq__ (2) | JSONPatchItem.__eq__ | == |
| __getitem__ (2) | JSONPatchItem.__getitem__ | [i] |
| __ne__ (2) | JSONPatchItem.__ne__ | != |
JSONPatchItemRaw¶
Methods¶
| [docs] | [source] |
|---|---|
| JSONPatchItemRaw | JSONPatchItemRaw.__init__ |
JSONPatchFilter¶
Methods¶
| [docs] | [source] | [logic-operator] |
|---|---|---|
| JSONPatchFilter | JSONPatchFilter.__init__ |
Operators¶
| [docs] | [source] | [logic-operator] |
|---|---|---|
| __eq__ (4) | JSONPatchFilter.__eq__ | == |
JSONPatch¶
Methods¶
Basic¶
| [docs] | [source] | [logic-operator] |
|---|---|---|
| JSONPatch | JSONPatch.__init__ | |
| __repr__ (5) | JSONPatch.__repr__ | repr |
| __str__ (5) | JSONPatch.__str__ | str |
Patch¶
Operators¶
| [docs] | [source] | [logic-operator] |
|---|---|---|
| __add__ (5) | JSONPatch.__add__ | + |
| __call__ (5) | JSONPatch.__call__ | exec |
| __eq__ (5) | JSONPatch.__eq__ | == |
| __getitem__ (5) | JSONPatch.__getitem__ | [i] |
| __iadd__ (5) | JSONPatch.__iadd__ | += |
| __isub__ (5) | JSONPatch.__isub__ | -= |
| __ne__ (5) | JSONPatch.__ne__ | != |
| __sub__ (5) | JSONPatch.__sub__ | - |
| __len__ (5) | JSONPatch.__len__ | len |
Iterators¶
| [docs] | [source] | [logic-operator] |
|---|---|---|
| __iter__ (5) | JSONPatch.__iter__ | -> |
jsondata.jsonpointer¶
Supports RFC6901 [RFC6901] and “Relative JSON Pointers - draft-handrews-relative-json-pointer-01” [RELPOINTER] .
Functions¶
| [docs] | [source] | [logic-operator] |
|---|---|---|
| fetch_pointerpath | fetch_pointerpath |
JSONPointer¶
Methods¶
Basic¶
Nodes¶
Operators¶
| [docs] | [source] | [logic-operator] |
|---|---|---|
| __add__ (6) | JSONPointer.__add__ | + |
| __call__ (6) | JSONPointer.__call__ | exec |
| __eq__ (6) | JSONPointer.__eq__ | == |
| __ge__ (6) | JSONPointer.__ge__ | >= |
| __gt__ (6) | JSONPointer.__gt__ | > |
| __iadd__ (6) | JSONPointer.__iadd__ | += |
| __le__ (6) | JSONPointer.__le__ | <= |
| __lt__ (6) | JSONPointer.__lt__ | < |
| __ne__ (6) | JSONPointer.__ne__ | != |
| __radd__ (6) | JSONPointer.__radd__ | x+ |
Iterators¶
| [docs] | [source] | [logic-operator] |
|---|---|---|
| iter_path | JSONPointer.iter_path | (path)-> |
| iter_path_nodes | JSONPointer.iter_path_nodes | (path-nodes)-> |
| iter_path_subpathdata | JSONPointer.iter_path_subpathdata | (path-nodes)-> |
| iter_path_subpaths | JSONPointer.iter_path_subpaths | (path-nodes)-> |