package granary

  1. Overview
  2. Docs
Pure-OCaml SQL engine

Install

dune-project
 Dependency

Authors

Maintainers

Sources

0.0.3.tar.gz
sha256=8b18780ea373be48301d9f333925860a2f9110fc0ac28684295118d72b65a67e
sha512=25ca3c9c5e2b528704a542502e0f37dc33ba003f65622d969b8c2b800778585f8ef0cf89b36e6679832e3993e8303aecddfc662742baf7044d6afe4a796b8f11

doc/granary.sql/Granary_sql/Json/index.html

Module Granary_sql.JsonSource

JSON value model and the SQLite json1 scalar functions.

Provides a parsed value tree, text (de)serialisation, type introspection, and the path-based accessors/mutators (path_get, path_set, path_insert, path_replace, path_remove) used to implement the SQL JSON functions.

Sourcetype value =
  1. | J_null
  2. | J_bool of bool
  3. | J_int of int64
  4. | J_float of float
  5. | J_string of string
  6. | J_array of value list
  7. | J_object of (string * value) list
Sourceval parse : string -> (value, string) result

Parse JSON text into a value, or Error msg on malformed input.

Sourceval to_string : value -> string

Serialise a value back to compact JSON text.

Sourceval type_name : value -> string

SQL json_type name of a value ("null"/"true"/"integer"/"object"/...).

Sourceval path_get : value -> string -> value option

path_get v p returns the value at JSON path p (e.g. "$.a[0]"), or None if the path does not resolve.

Sourceval path_set : value -> string -> value -> value

path_set v p x sets the value at path p to x, creating or overwriting as needed (SQL json_set).

Sourceval path_insert : value -> string -> value -> value

path_insert v p x sets path p to x only if it does not already exist (SQL json_insert).

Sourceval path_replace : value -> string -> value -> value

path_replace v p x sets path p to x only if it already exists (SQL json_replace).

Sourceval path_remove : value -> string -> value

path_remove v p removes the element at path p (SQL json_remove).