fsqlite-ext-json
JSON1 functions and virtual tables for FrankenSQLite.
Overview
This crate implements the SQLite JSON1 extension, providing JSON validation, parsing, extraction, mutation, formatting, and virtual table access. It supports the full JSON1 function surface including JSONB binary encoding/decoding, JSON5 validation, path-based extraction with SQLite semantics (single-path returns native SQL types, multi-path returns a JSON array), mutators (set, insert, replace, remove, patch), aggregate functions (group_array, group_object), and the json_each/json_tree virtual tables for flattening JSON structures.
Path syntax follows SQLite conventions: $ (root), $.key (object member), $."key.with.dots" (quoted member), $[N] (array index), $[#] (append), $[#-N] (reverse index).
This crate depends on fsqlite-types, fsqlite-error, fsqlite-func, serde_json, and json5.
Key Types
JsonTableRow- A row fromjson_eachorjson_tree, containing key, value, type, atom, id, parent, fullkey, and pathJsonEachVtab/JsonEachCursor- Virtual table and cursor forjson_each()(flat iteration over JSON values)JsonTreeVtab/JsonTreeCursor- Virtual table and cursor forjson_tree()(recursive iteration)JsonFunc,JsonValidFunc,JsonTypeFunc,JsonExtractFunc- Scalar function implementations for core JSON operationsJsonArrayFunc,JsonObjectFunc,JsonQuoteFunc- Scalar constructorsJsonSetFunc,JsonInsertFunc,JsonReplaceFunc,JsonRemoveFunc,JsonPatchFunc- Scalar mutatorsJsonArrayLengthFunc,JsonErrorPositionFunc,JsonPrettyFunc- Scalar utility functions
Key Functions
json(input)- Parse and minify JSON textjson_valid(input, flags)- Validate JSON text under configurable flags (RFC-8259, JSON5, JSONB superficial, JSONB strict)jsonb(input)/json_from_jsonb(input)- Convert between JSON text and JSONB binary formatjson_type(input, path)- Return the JSON type name at root or a given pathjson_extract(input, paths)- Extract values by path with SQLite single/multi-path semanticsjson_arrow(input, path)/json_double_arrow(input, path)-->and->>operator equivalentsjson_set,json_insert,json_replace,json_remove,json_patch- In-place JSON mutation (withjsonb_*variants)json_array,json_object,json_quote- JSON value constructorsjson_group_array,json_group_object- Aggregate functions (withjsonb_*variants)json_each(input, path)/json_tree(input, path)- Flatten JSON into virtual table rowsjson_pretty(input, indent)- Pretty-print JSON with configurable indentationjson_error_position(input)- Return the byte offset of the first JSON parse errorjson_array_length(input, path)- Return the length of a JSON arrayregister_json_scalars(registry)- Register all JSON scalar functions into a function registry
Dependencies
fsqlite-typesfsqlite-errorfsqlite-funcserde_jsonjson5
License
MIT