djson.pl

json_term(+Json:atom, -Term) is multi
json_term(-Json:atom, +Term) is det
True if Json is a serialization of Term in JSON notation. For single use, Term can be a Prolog term with JSON-like notation. For example,
Term = {
    name: Name,
    occupation: Job
}

json_term/2 considers it acceptable for Json to have extraneous fields that are not present in Term. This allows one to pattern match against a Json document without having to specify every imagineable key.

When dealing repeatedly with the same terms and JSON structures, it's most convenient to declare additional clauses for json//1.

json(?Term)//[multifile]
Multifile hook for declaring a JSON-Prolog relation. When adding clauses to this predicate, one typically calls json//1 recursively with a JSON-like argument to describe the desired structure.

For example,

:- multifile djson:json//1.
djson:json(person(Name,Age)) -->
    json({ name: Name, age: Age }).
is_like_json(+Term) is semidet
True if Term is JSON-like. A JSON-like term is one that looks the same as JSON notation. For example,
?- is_like_json({ hi: world }).
true.
?- is_like_json([ a, b, 73 ]).
true.
?- is_like_json(foo(_,_)).
false.