[Pharo-users] How to write out simple Json?

Sven Van Caekenberghe sven at stfx.eu
Thu Feb 28 08:16:48 EST 2019


STONJSON toString: { #id->1. #name->'tim' } asDictionary.

JSON cannot deal with Associations by themselves.

> On 28 Feb 2019, at 14:05, Tim Mackinnon <tim at testit.works> wrote:
> 
> I am stumped about how to write out some simple json (for a config file). I didn't think I need Neo, and STONJSON would be fine but it seems like creating items like: 
> 
> { 'id'-> self id. 'name' -> self name }
> 
> gives an error about the association. I think you have to do: { ('id'-> self id) asDictionary. ('name' -> self name) asDictionary } everywhere….
> 
> But when I switch over to NeoJsonWriter it also complains about Assocations too. I just want a simple output like:
> { "id" : 12, "name" : "tim” }
> 
> I thought it was simple to do this? Am I missing something obvious.
> 
> Tim




More information about the Pharo-users mailing list