Module json

This module provides JSON object access. Compared to tagged structures the JSON objects do not have a tag and their key value pairs are not automatically sorted. In addition, it is more common for JSON objects to use strings instead of atoms as keys. Further, except for the strings syntax, JSON objects do not require some new syntax.

Examples:
?- set_prolog_flag(double_quotes, string).
Yes
?- X = {"y":2,"x":1}.
X = {"y":2,"x":1}

The set of predicates for JSON objects is again modelled after the corresponding SWI-Prolog library for Prolog dicts. The predicates thus resembles our predicates for tagged structures. The JSON objects can be also used in connection with the dot notation. Again, this functionality is provided through the module "func".

The following json are provided:

is_json(X):
The predicate succeeds when X is a JSON object.
get_json(K, S, V):
The predicate succeeds with the value V of the key K in the JSON object S.
select_json(S, T, R):
The predicate succeeds when R unifies with the removal of the key value pairs of S from the JSON object T.
del_json(K, S, V, T):
The predicate succeeds in T with the deletion of the key K from the JSON object S and in V with the old value.
put_json(S, T, R):
The predicate succeeds in R with the replacement of the key value pairs of S in the JSON object T.
put_json(K, S, V, T):
The predicate succeeds in T with the replacement of the new value V for the key K by in the JSON object S.

Kommentare