package mcp-kit

  1. Overview
  2. Docs

Module Jsonschema_core.InstanceSource

JSON instance data model for JSON Schema.

Provides equality, type checking, and utility functions that match the JSON Schema specification semantics (not OCaml structural equality).

Sourceval json_equal : json -> json -> bool

Deep equality per JSON Schema spec. Numbers compare by mathematical value: 1 = 1.0. Booleans are never equal to numbers: true <> 1. Objects compare as unordered key-value sets.

Sourceval utf8_length : string -> int

Count Unicode codepoints in a UTF-8 string. This is the "length" used by maxLength/minLength per spec.

Sourceval to_float : json -> float option

Convert a JSON number to float. Returns None for non-numbers.

Sourceval to_int : json -> int option

Convert a JSON number to an OCaml native int if possible. Returns None for non-integers, non-numbers, and integer values outside the native int range. This is not an arbitrary-precision JSON integer conversion: is_type "integer" (`Intlit s) can be true while to_int (`Intlit s) is None. Float 1.0 returns Some 1.

Sourceval is_type : string -> json -> bool

Check if a JSON value matches a JSON Schema type name. Type names: "null", "boolean", "object", "array", "number", "string", "integer". "integer" matches any number with zero fractional part.