Dict, Json & type

22 views
Skip to first unread message

Ralf Wolter

unread,
Aug 18, 2016, 2:38:44 AM8/18/16
to SWI-Prolog
My application uses a web socket hub to communicate between a Javascript Client and a Prolog server. The communication is in json format. I'm using atom_json_dict to convert the hub.queue.event data into a dict.

atom_string(Atom, Data),
atom_json_dict
(Atom, JSONDict, []),

This does not convert the type field to the dictionary tag. According to the manual json_read_dict does convert the type field. I would like to use this predicate but it requires input as a stream while http/hub provides a string.

How can I convert a string to a stream for json_read_dict and is it worth it?

Ralf

Jan Wielemaker

unread,
Aug 18, 2016, 3:13:14 AM8/18/16
to Ralf Wolter, SWI-Prolog
On 08/18/2016 08:38 AM, Ralf Wolter wrote:
> My application uses a web socket hub to communicate between a Javascript
> Client and a Prolog server. The communication is in json format. I'm
> using atom_json_dict to convert the hub.queue.event data into a dict.
>
> |
> atom_string(Atom,Data),
> atom_json_dict(Atom,JSONDict,[]),
> |
>
> This does not convert the type field to the dictionary tag. According to
> the manual json_read_dict does convert the type field. I would like to
> use this predicate but it requires input as a stream while http/hub
> provides a string.
>
> How can I convert a string to a stream for json_read_dict and is it
> worth it?

open_string/2

--- Jan

>
> Ralf
>
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swi-prolog+...@googlegroups.com
> <mailto:swi-prolog+...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/swi-prolog.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages