protocol

json_schema_protocol

JSON Schema parser and validator protocol.

Availability:
logtalk_load(json_schema(loader))
Author: Paulo Moura
Version: 1:0:1
Date: 2026-06-14
Compilation flags:
static
Dependencies:
(none)
Remarks:
(none)
Inherited public predicates:
(none)

Public predicates

parse/2

Parses a JSON schema from the given source (file(Path), stream(Stream), codes(List), chars(List), or atom(Atom)) into a schema term.

Compilation flags:
static
Template:
parse(Source,Schema)
Mode and number of proofs:
parse(++compound,--term) - one_or_error
Exceptions:
Source is a variable:
instantiation_error
Source is neither a variable nor a valid JSON source term or does not contain parsable JSON:
domain_error(json_source,Source)
The parsed JSON value is not a valid JSON Schema term:
domain_error(json_schema,Schema)

validate/2

Validates a JSON term against a parsed schema. Succeeds if the JSON term is valid according to the schema.

Compilation flags:
static
Template:
validate(Schema,JSON)
Mode and number of proofs:
validate(+term,+term) - zero_or_one

validate/3

Validates a JSON term against a parsed schema. Returns a list of validation errors (empty list if valid).

Compilation flags:
static
Template:
validate(Schema,JSON,Errors)
Mode and number of proofs:
validate(+term,+term,--list) - one

Protected predicates

(none)

Private predicates

(none)

Operators

(none)