# JSON string bound to Var converted to dict

**URL:** <https://swi-prolog.discourse.group/t/json-string-bound-to-var-converted-to-dict/1942>\
**Category:** Predicate\
**Created:** [March 2, 2020, 9:19am UTC](https://swi-prolog.discourse.group/t/json-string-bound-to-var-converted-to-dict/1942 "2020-03-02T09:19:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![grossdan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/grossdan/32/23_2.png) [@grossdan](https://swi-prolog.discourse.group/u/grossdan)\
**Post date:** [March 2, 2020, 9:19am UTC](https://swi-prolog.discourse.group/t/json-string-bound-to-var-converted-to-dict/1942/1 "2020-03-02T09:19:57Z")

</div>

Hello,

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

thanks,

Dan

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [March 2, 2020, 9:40am UTC](https://swi-prolog.discourse.group/t/json-string-bound-to-var-converted-to-dict/1942/2 "2020-03-02T09:40:18Z")

</div>

See [https://www.swi-prolog.org/pldoc/doc\_for?object=atom\_json\_dict/3](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.
