JSON encoder and decoder

Author(s): Jose F. Morales.

Stability: [devel] Currently the subject of active development and/or research. Functionality may be limited and API and/or functionality may change without warning or deprecation period. Not recommended yet for use in production.


This module defines a term representation for JSON (JavaScript Object Notation), as well as encoders and decoders.

Usage and interface

Documentation on exports

REGTYPEjson/1

Usage:

A JSON object.

json(json(Attrs)) :-
        json_attrs(Attrs).

    Usage:

    Attributes (pairs of key/value) of a JSON object.

    json_attrs([]).
    json_attrs([X|Xs]) :-
            json_attr(X),
            json_attrs(Xs).
    

      A regular type, defined as follows:
      json_attr(Id=Val) :-
              atm(Id),
              json_val(Val).
      

      REGTYPEjson_val/1
      A regular type, defined as follows:
      json_val(string(X)) :-
              string(X).
      json_val(X) :-
              number(X).
      json_val(X) :-
              json(X).
      json_val(X) :-
              json_list(X).
      json_val(true).
      json_val(false).
      json_val(null).
      

      Usage:

      A list of JSON elements

        Usage:json_to_string(Term,String)

        Encode a JSON Term as a character list.

        • Call and exit should be compatible with:
          (json:json/1)A JSON object.
          json(json(Attrs)) :-
                  json_attrs(Attrs).
          

          (basic_props:string/1)String is a string (a list of character codes).
        • The following properties should hold at call time:
          (term_typing:nonvar/1)Term is currently a term which is not a free variable.

        Usage:string_to_json(String,Term)

        Decode a character list as a JSON Term.

        • Call and exit should be compatible with:
          (basic_props:string/1)String is a string (a list of character codes).
          (json:json/1)A JSON object.
          json(json(Attrs)) :-
                  json_attrs(Attrs).
          
        • The following properties should hold at call time:
          (term_typing:nonvar/1)String is currently a term which is not a free variable.

        PREDICATEjson_get/3
        No further documentation available for this predicate.

        No further documentation available for this predicate.

        No further documentation available for this predicate.

        No further documentation available for this predicate.

        PREDICATEjson_as_atm/2
        No further documentation available for this predicate.

        PREDICATEjson_as_num/2
        No further documentation available for this predicate.

        Documentation on imports

        This module has the following direct dependencies:

        Known bugs and planned improvements

        • The grammar probably incomplete. See http://json.org for a complete reference.
        • Missing tests. See http://json.org/example.html for many examples.
        • For a parser, any JSON value may be acceptable. However only object or array are valid as top-level for JSON text