Did you know ... Search Documentation:
Pack json_answer -- prolog/json_answer.pl
PublicShow source

This is a convenience module to convert a prolog query into a JSON answer for IPC

 query(+Term, +Stream) is semidet
Writes the JSON to the given stream
deprecated
- term_to_dict_list/2
 query(+Term) is semidet
Outputs JSON to current_output
deprecated
- term_to_dict_list/2
 term_to_dict(+Term, -Dict) is semidet
Converts a compound term to a dict
 term_to_dict_list(+Term, -DictList) is semidet
Converts a compound term to a list of dicts
?- assert(friend(alex, luke)),
   assert(friend(donna, eric)),
   assert(friend(donna, mary)).
true
?- term_to_dict_list(friend(donna, _), DictList),
   json:json_write_dict(current_output, DictList).
[ {"friend": ["donna", "eric" ]},  {"friend": ["donna", "mary" ]} ]
DictList = [_{friend:[donna, eric]}, _{friend:[donna, mary]}].