Interesting ... for some reason, I believed that PicoLisp did not contain a json parser !!! - perhaps because, a search for json on https://picolisp.com/wiki/?Documentation takes me to the external repositories section :)
pipe is awesome :) - I was looking for just that. It occurred to me that the "@lib/json.l" also seems to work with scaling a little different from my expectation - *kashyap@continue*:*~*$ pil + : (load "@lib/json.l") -> printJson : (scl 2) -> 2 : (parseJson "{\"a\": 10.1}") -> (("a" . 1010)) : (parseJson "{\"a\": 10}") -> (("a" . 10)) : Shouldn't 10 be scaled to 1000? Did I miss something here or is there something I need to do so that all the numbers are normalized? Regards, Kashyap On Sat, May 4, 2019 at 11:49 PM Alexander Burger <a...@software-lab.de> wrote: > On Sat, May 04, 2019 at 11:27:28PM -0700, C K Kashyap wrote: > > Thank you so much Alex ... What would it take to transform this code to > > handle string as input instead of file stream? > > There are two ways: > > 1. To parse strings directly, then a different code is needed. As an > example, > see 'parseJson' (strings) versus 'readJson' (input stream) in > "@lib/json.l". > > 2. Simpler is to use a pipe, printing strings to one end and reading from > the > other: > > : (parseJson "{a: 7, s: \"abc\"}") > -> ((a . 7) (s . "abc")) > > : (pipe (prinl "{a: 7, s: \"abc\"}") > (readJson) ) > -> ((a . 7) (s . "abc")) > > ☺/ A!ex > > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe >