Module ijson

Module ijson 

Source
Expand description

Incremental JSON (iJSON): path-based operations on JSON data. Port of Go’s pkg/ijson/ijson.go.

iJSON allows expressing JSON updates as a series of commands:

  • set: Set a value at a path
  • del: Delete a value at a path
  • append: Append a value to an array at a path

Paths are arrays of string keys and integer indices, e.g.: ["users", 0, "name"] refers to data.users[0].name

Structs§

Command
An iJSON command: set, delete, or append.
SetPathOpts
Options for set_path operations.

Enums§

IJsonError
Error type for iJSON operations.
PathElement
Element of a JSON path: either a string key or integer index.

Constants§

CMD_APPEND
CMD_DEL
CMD_SET
Command type constants.

Functions§

apply_command
Apply a single iJSON command to data.
apply_commands
Apply a sequence of iJSON commands to data.
compact_ijson
Compact iJSON: apply all commands and produce a single set command.
format_path
Format a path for display: $users[0].name
get_path
Get a value at the specified path within JSON data. Returns None if the path doesn’t exist (not an error).
parse_ijson
Parse newline-delimited iJSON commands.
parse_simple_path
Parse a simple dot-separated path string. “users.0.name” → [Key(“users”), Index(0), Key(“name”)]
path_to_values 🔒
Convert Path to JSON values for serialization.
set_path
Set a value at the specified path within JSON data. Creates intermediate objects/arrays as needed. Returns the modified data.
set_path_recursive 🔒
value_type_name 🔒
Get a human-readable type name for a JSON value.
values_to_path 🔒
Convert JSON values to Path.

Type Aliases§

Path
A JSON path is a sequence of string keys and integer indices. Example: ["users", 0, "name"]data.users[0].name