json-parse with inner double quote

Started by kosh, June 20, 2013, 04:56:05 AM

Previous topic - Next topic

kosh

Hi.



json-parse cannot handle JSON data with inner double quote chars.


> (setf data [text]{"foo": ["bar", ""baz""]}[/text])
"{"foo": ["bar", "\"baz\""]}"
> (json-parse data)
nil
> (json-error)
("invalid JSON array format" 19)


This problem doesn't occur in previous json module.


> (module "json.lsp")
MAIN
> (json2expr data)
(("foo" ("bar" ""baz"")))


P.S. Is json module no longer available?

Documentation page is alive. but download link is 404.

http://www.newlisp.org/code/modules/json.lsp.html">//http://www.newlisp.org/code/modules/json.lsp.html

Lutz

#1
Thanks Kosh, now fixed here:



http://www.newlisp.org/downloads/development/inprogress/">http://www.newlisp.org/downloads/develo ... nprogress/">http://www.newlisp.org/downloads/development/inprogress/



newLISP v.10.5.2 64-bit on OSX IPv4/6 UTF-8 libffi, options: newlisp -h

> (setf data [text]{"foo": ["bar", ""baz""]}[/text])
"{"foo": ["bar", "\"baz\""]}"
>  (json-parse data)
(("foo" ("bar" ""baz"")))
>


Ps: also restored the source for the old json.lsp

kosh

#2
Thanks Lutz.


newLISP v.10.5.2 32-bit on Win32 IPv4/6 UTF-8 libffi, options: newlisp -h

> (json-parse [text]{"a backslash":"\"}[/text])
(("a backslash" "\\"))


This retun value is maybe (("a backslash" "\"))



Regards.

Lutz

#3
Thanks Kosh, I fixed the escaped back slash:



> (json-parse [text]{"a backslash":"\"}[/text])
(("a backslash" "\"))


... for cases in your other post, where json-parse lets pass certain misformed content, json-parse will stay as it is:



http://www.newlisp.org/downloads/development/inprogress/">http://www.newlisp.org/downloads/develo ... nprogress/">http://www.newlisp.org/downloads/development/inprogress/