JSON string bound to Var converted to dict


Is there an easy way to get a JSON String bound to a variable converted to a dict. i noticed the json to dict calls in http/josn but these seem to work with streams.

can a string we made into a stream for that purpose, or is there a different way



See https://www.swi-prolog.org/pldoc/doc_for?object=atom_json_dict/3. As with most text conversion predicates, anything text-like is accepted as input.

P.s. Pushed a fix to use the newer open_string/2 rather than memory files for better performance, allowing list of character (codes) and raising an exception on illegal input.

P.s. “String bound to a variable” doesn’t make sense in Prolog. A term can be a variable or a string (or some more things), but once a variable term is unified with a string it is a string. The variable simply doesn’t exist anymore. Logical variables are not like buckets in imperative languages in which you store something.

[edit] This stuff should eventually be moved outside the HTTP package.