Defined in awkward._v2.operations.convert.ak_from_json_schema on line 13.

ak._v2.ak_from_json_schema.from_json_schema(source, schema, highlevel=True, behavior=None, output_initial_size=1024, output_resize_factor=1.5)
  • source (str or bytes) – JSON-formatted string to convert into an array.

  • schema (str, bytes, or nested dicts) – JSONSchema to assume in the parsing. The JSON data are not validated against the schema; the schema is only used to accelerate parsing.

  • highlevel (bool) – If True, return an ak.Array; otherwise, return a low-level ak.layout.Content subclass.

  • behavior (None or dict) – Custom ak.behavior for the output array, if high-level.

  • output_initial_size (int) – Initial size (in bytes) of output buffers, which grow as needed to accommodate the size of the dataset.

  • output_resize_factor (float) – Resize multiplier for output buffers, which determines how quickly they grow; should be strictly greater than 1.

Converts a JSON string into an Awkward Array, using a JSONSchema to accelerate the parsing of the source and building of the output. The JSON data are not validated against the schema; the schema is assumed to be correct.

Supported JSONSchema elements:

  • The root of the schema must be "type": "array" or "type": "object".

  • Every level must have a "type", which can only name one type (as a string or length-1 list) or one type and "null" (as a length-2 list).

  • "type": "boolean" → 1-byte boolean values.

  • "type": "integer" → 8-byte integer values. Numbers may include a fractional part, as per the JSONSchema specification, but this function ignores any fractional part.

  • "type": "number" → 8-byte floating-point values.

  • "type": "string" → UTF-8 encoded strings. All JSON escape sequences are supported. Remember that the source data are ASCII; Unicode is derived from “\uXXXX” escape sequences. If an "enum" is given, strings are represented as categorical values (ak.layout.IndexedArray or ak.layout.IndexedOptionArray).

  • "type": "array" → nested lists. The "items" must be specified. If "minItems" and "maxItems" are specified and equal to each other, the list has regular-type (ak.types.RegularType); otherwise, it has variable-length type (ak.types.ListType).

  • "type": "object" → nested records. The "properties" must be specified, and any properties in the data not described by "properties" will not appear in the output.

See also ak.from_json and ak.to_json.