Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/JSON/Prolog/json-1.pro
Normal file
22
Task/JSON/Prolog/json-1.pro
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
:- use_module([ library(http/json),
|
||||
library(func) ]).
|
||||
|
||||
test_json('{"widget": { "debug": "on", "window": { "title": "Sample Konfabulator Widget", "name": "main_window", "width": 500, "height": 500 }, "image": { "src": "Images/Sun.png", "name": "sun1", "hOffset": 250, "vOffset": 250, "alignment": "center" }, "text": { "data": "Click Here", "size": 36, "style": "bold", "name": "text1", "hOffset": 250, "vOffset": 100, "alignment": "center", "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;" }}}').
|
||||
|
||||
reading_JSON_term :-
|
||||
atom_json_dict(test_json(~), Dict, []), %% This accomplishes reading in the JSON data
|
||||
writeln( 'JSON as Prolog dict: ~w~n'
|
||||
$ Dict),
|
||||
writeln( 'Access field "widget.text.data": ~s~n'
|
||||
$ Dict.widget.text.data),
|
||||
writeln( 'Alter field "widget": ~w~n'
|
||||
$ Dict.put(widget, "Altered")).
|
||||
|
||||
searalize_a_JSON_term :-
|
||||
Dict = _{book:_{title:"To Mock a Mocking Bird",
|
||||
author:_{first_name:"Ramond",
|
||||
last_name:"Smullyan"},
|
||||
publisher:"Alfred A. Knopf",
|
||||
year:1985
|
||||
}},
|
||||
json_write(current_output, Dict). %% This accomplishes serializing the JSON object.
|
||||
19
Task/JSON/Prolog/json-2.pro
Normal file
19
Task/JSON/Prolog/json-2.pro
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
?- reading_JSON_term.
|
||||
JSON as Prolog dict: _G5217{widget:_G5207{debug:on,image:_G5123{alignment:center,hOffset:250,name:sun1,src:Images/Sun.png,vOffset:250},text:_G5189{alignment:center,data:Click Here,hOffset:250,name:text1,onMouseUp:sun1.opacity = (sun1.opacity / 100) * 90;,size:36,style:bold,vOffset:100},window:_G5077{height:500,name:main_window,title:Sample Konfabulator Widget,width:500}}}
|
||||
|
||||
Access field "widget.text.data": Click Here
|
||||
|
||||
Alter field "widget": _G5217{widget:Altered}
|
||||
|
||||
true.
|
||||
|
||||
?- searalize_a_JSON_term.
|
||||
{
|
||||
"book": {
|
||||
"author": {"first_name":"Ramond", "last_name":"Smullyan"},
|
||||
"publisher":"Alfred A. Knopf",
|
||||
"title":"To Mock a Mocking Bird",
|
||||
"year":1985
|
||||
}
|
||||
}
|
||||
true.
|
||||
Loading…
Add table
Add a link
Reference in a new issue