Code: Select all
implement main
open core
constants
json : string = @'
{
"f_int" : 12,
"f_object" :
{
"nested_1" : false,
"nested_2" : [1, 5, { "A": "a" }, 7]
},
"f_string" : "This is a string"
}'.
clauses
run() :-
% Parse the json string as a jsonObject
JSON = jsonObject::fromString(json),
stdio::writef("JSON = %p\n", JSON),
F_Object_value = JSON:get("f_object"), % unpack the object from the json::jsonValue
json::o(F_Object) == F_Object_value,
stdio::writef("F_Object = %p\n", F_Object),
F_Object_2 = JSON:get_object("f_object"),
stdio::writef("F_Object_2 = %p\n", F_Object_2),
Nested_2 = F_Object:get_array("nested_2"),
stdio::writef("Nested_2 = %p\n", Nested_2).
end implement main