Did you know ... | Search Documentation: |
Predicate json_read/2 |
:- use_module(library(http/json)).
json(NameValueList)
,
where NameValueList is a list of Name=Value. Name is an atom created
from the JSON string.true
and false
are
mapped -like JPL- to @(true) and @(false).null
is mapped to the Prolog term
@(null)Here is a complete example in JSON and its corresponding Prolog term.
{ "name":"Demo term", "created": { "day":null, "month":"December", "year":2007 }, "confirmed":true, "members":[1,2,3] }
json([ name='Demo term', created=json([day= @null, month='December', year=2007]), confirmed= @true, members=[1, 2, 3] ])
The following options are processed:
null
. Default
@(null)true
. Default
@(true)false
. Default
@(false)error
):
==
error
, throw
an unexpected end of file syntax error
Returning an status term is required to process
Concatenated
JSON. Suggested values are @(eof)
or end_of_file
.
atom
.
The alternative is string
, producing a packed string
object. Please note that codes
or chars
would
produce ambiguous output and are therefore not supported.