Discussions related to Visual Prolog
Eki Laitila
Posts: 1
Joined: 21 Oct 2025 17:52

JSON and presenters

Post by Eki Laitila »

Can presenters be used to handle JSONs? The example below has been taken from one discussion here.

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
User avatar
Thomas Linder Puls
VIP Member
Posts: 1482
Joined: 28 Feb 2000 0:01

Re: JSON and presenters

Post by Thomas Linder Puls »

Yes, the '%p' in the format strings invokes presentation on the parameter.
Regards Thomas Linder Puls
PDC