8.1 library(http/json): Reading and writing JSON serialization
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog HTTP support
        • Supporting JSON
          • library(http/json): Reading and writing JSON serialization
            • atom_json_term/3
            • json_read/2
            • json_read/3
            • json_write/2
            • json_write/3
            • json_write_hook/4
            • json_dict_pairs/2
            • is_json_term/1
            • is_json_term/2
            • json_read_dict/2
            • json_read_dict/3
            • json_write_dict/2
            • json_write_dict/3
            • atom_json_dict/3
            • json/4
Availability::- use_module(library(http/json)).
Source[det]json(+Content, +Vars, +VarDict, -JSON)
The predicate json/4 implements JSON quasi quotations. These quotations produce a JSON dict that is suitable for json_write_dict/2. The quasi quoter only accepts valid, but possibly partial JSON documents. The quoter replaces content whose value is a Prolog variable that appears in the argument list of the json indicator. Notably, you can't use a Prolog variable in place of an object key. Here is an example.
  {|json(Name)||
      { "name": Name,
        "created": {
          "day":null,
          "month":"December",
          "year":2007
        },
        "confirmed":true,
        "members":[1,2,3]
      }
  |}.