Of you load the JSON package from Squeaksource (http://www.squeaksource.com/JSON.html)
You can do a JSON render: { 'track' -> 'pharo'. 'language' -> 'smalltalk'. 'exercises' -> { 'slug' -> 'hello'. 'id' -> 55. 'topics' -> #('a' 'b' 'c') } } and get a Json string or add e.g. Object>>#asJsonString ^JSON render: self Tim Mackinnon wrote >> On 1 Mar 2019, at 10:35, Sven Van Caekenberghe < > sven@ > > wrote: >> >> Forget about the way you are trying to implement it, to what would >> >> { #key->#value. 1. true } >> >> be rendered in JSON ? >> >> { "key":"value", 1, true } >> >> or >> >> [ "key":"value", 1, true ] >> >> Both are illegal JSON. > > > You didn’t read what I said - with those 2 tiny changes - both of those > given an exception just like STONJSON - the only difference is that I > don’t have to put asDictionary everywhere. > > Anyway - I think I’ve learned a lot from this discussion - and as Pharo is > malleable I can do my little nasty subclass until I get burned and then I > will probably adopt a proper Config object like Henrik mentioned ;) > > Just as a small additional question - when you do : > > ex := { > #track->#pharo. > #language->#smalltalk. > #exercises->{ > #slug->'hello'. > #id->55. > #topics->#('a' 'b' 'c') } asDictionary } asDictionary. > > Am I right in thinking that with asDictionary the order won’t be > deterministic (which is valid for JSON dictionaries, but annoying for > diffing config files). This is why I was doing asOrderedDictionary as I > though I had seen it change on me a few times when I was generating > output. > > Tim -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html