jsondata.__init__

The data represented as in-memory ‘json’ compatible structure, with dynamically added and/or removed branches. The components are:

  • JSONData: The main class JSONData provides for the core interface.
  • JSONDataSerializer: Derived from JSONData provides for serialization and integration of documents and sub-documents.
  • JSONPointer: The JSONPointer module provides for addressing in accordance to RCF7159 and RFC6901.
  • JSONPatch: The JSONPatch module provides features in accordance to RFC6902.
  • JSONDiff: Structure utilities.

Module

Modular processing of JSON data by trees and branches, pointers and patches.

Constants

Assigment Types

  • C_REF(0) - OP-Copy: Copy reference.
  • C_DEEP(1) - OP-Copy: Copy deep.
  • C_SHALLOW(2) - OP-Copy: Copy shallow.

Branch-Operations Types

  • B_ALL(0) - OP-On-Branches: in any case.
  • B_AND(1) - OP-On-Branches: only when both present.
  • B_OR(2) - OP-On-Branches: if one is present.
  • B_XOR(3) - OP-On-Branches: if only one is present.
  • B_MOD(4) - OP-On-Branches: modulo of branches.
  • B_SUB(5) - OP-On-Branches: subtract branches.
  • B_MULT(6) - OP-On-Branches: add a pattern to the whole tree.
  • B_DIV(7) - OP-On-Branches: remove a pattern from the whole tree.

Character Display

  • CHARS_RAW(0) - display character set as raw
  • CHARS_STR(1) - display character set as str
  • CHARS_UTF(2) - display character set as utf

Data Scopes

  • SD_BOTH(0) - Apply on mixed input and output data.
  • SD_INPUT(1) - Apply on input data.
  • SD_OUTPUT(2) - Apply on output data.

Display Style

  • PT_PATH(0) - Displays a list of items.
  • PT_RFC6901(1) - Displays rfc6901 strings.
  • PT_NODE(2) - Displays the node.

Line Handling of Overflow

  • LINE_CUT(0) - force line fit
  • LINE_WRAP(1) - wrap line in order to fit to length

Modes

Data

  • MJ_RFC4627(1) - The first JSON RFC by July 2006 [RFC4627].
  • MJ_RFC7493(2) - The iJSON RFC - for now same as RFC7159 [RFC7493].
  • MJ_RFC7159(2) - The JSON RFC by ‘now’, by March 2014 [RFC7159].
  • MJ_RFC8259(4) - The JSON RFC by December 2017 [RFC8259].
  • MJ_ECMA264(16) - The first JSON EMCMA standard [ECMA264].
  • MJ_RFC6901(32) - JSONPointer first IETF RFC [RFC6901].
  • MJ_RELPOINTER(64) - JSONPointer - relative pointer Draft-01 January 2018 [RELPOINTER].
  • MJ_RFC6902(128) - JSONPatch first IETF RFC [RFC6902].

Schema

  • MS_DRAFT3(512) - The first supported JSONSchema IETF-Draft.
  • MS_DRAFT4(1024) - The current supported JSONSchema IETF-Draft [ZYP].

Defaults:

  • MS_ON = MS_DRAFT4 - The current default.
  • MS_OFF(0) - No validation.
  • MODE_SCHEMA_DEFAULT = MS_OFF - The current default validation mode.

Match Criteria

Match criteria for node comparison.

  • MATCH_INSERT(0) - For dicts.
  • MATCH_NO(1) - Negates the whole set.
  • MATCH_KEY(2) - For dicts.
  • MATCH_CHLDATTR(3) - For dicts and lists.
  • MATCH_INDEX(4) - For lists.
  • MATCH_MEM(5) - For dicts(value) and lists.
  • MATCH_NEW(6) - If not present create a new, else ignore and keep present untouched.
  • MATCH_PRESENT(7) - Check all are present, else fails.

Match Sets

Defines the returned sets of matches.

  • M_FIRST(1) - The first match only.
  • M_LAST(2) - The last match only.
  • M_ALL(4) - All matches.

JSON Notation

Notation of the API - in/out.

  • NOTATION_NATIVE(0) - JSON notation in accordance to RFC7159. This is the default.
  • NOTATION_JSON(1) - JSON notation in accordance to RFC7159 with RFC3986.
  • NOTATION_JSON_REL(2) - JSON notation as relative pointer.
  • NOTATION_HTTP_FRAGMENT(1) - JSON notation in accordance to RFC7159 with RFC3986.

Operator Scopes

  • SC_DATA(0) - OP-Scope: the managed JSON data only.
  • SC_SCHEMA(1) - OP-Scope: the managed JSON schema only.
  • SC_JSON(2) - OP-Scope: the managed JSON data and schema only.
  • SC_OBJ(3) - OP-Scope: the attributes of current instance.
  • SC_ALL(4) - OP-Scope: the complete object, including data.
  • C_DEFAULT = C_REF - Default value.

Pointer Display

  • PT_PATH = 0
  • PT_RFC6901 = 1

Return Types

  • R_OBJ(0) - Return object of type self.
  • R_DATA(1) - Return self.data.
  • R_JDATA(2) 0 Return object of type JSONData.

Search Parameters

  • SEARCH_FIRST(0) - Break display after first match.
  • SEARCH_ALL(1) - List all matches.

Sort Order

  • S_NONE = 0 - no sort
  • S_SIMPLE = 1 - goups upper lower

Exceptions

exception jsondata.__init__.JSONDataAmbiguityError(requested, *sources)[source]

Error ambiguity of provided parameters.

exception jsondata.__init__.JSONDataError(*arg)[source]

base Exception.

exception jsondata.__init__.JSONDataIndexError(*arg)[source]

Error on key.

exception jsondata.__init__.JSONDataKeyError(*arg)[source]

Error on key.

exception jsondata.__init__.JSONDataModeError(*arg)[source]

Type error of source file content.

exception jsondata.__init__.JSONDataNodeTypeError(*arg)[source]

Error on NodeTypes.

exception jsondata.__init__.JSONDataParameterError(*arg)[source]

Erroneous parameters.

exception jsondata.__init__.JSONDataPatchError(*arg)[source]
exception jsondata.__init__.JSONDataPatchItemError(*arg)[source]
exception jsondata.__init__.JSONDataPathError(*arg)[source]

Error on key.

exception jsondata.__init__.JSONDataSourceFileError(*arg)[source]

Error on read of a source file.

exception jsondata.__init__.JSONDataTargetFileError(*arg)[source]

Error on writing a file.

exception jsondata.__init__.JSONDataValueError(*arg)[source]

Error on a value.

exception jsondata.__init__.JSONPointerError(*arg)[source]

Pointer error.