Featuring the Dragonfly web framework
-
kosh
- Posts: 72
- Joined: Sun Sep 13, 2009 5:38 am
- Location: Japan
-
Contact:
Post
by kosh »
Hi.
json-parse cannot handle JSON data with inner double quote chars.
Code: Select all
> (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.
Code: Select all
> (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
-
Lutz
- Posts: 5289
- Joined: Thu Sep 26, 2002 4:45 pm
- Location: Pasadena, California
-
Contact:
Post
by Lutz »
Thanks Kosh, now fixed here:
http://www.newlisp.org/downloads/develo ... nprogress/
Code: Select all
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
- Posts: 72
- Joined: Sun Sep 13, 2009 5:38 am
- Location: Japan
-
Contact:
Post
by kosh »
Thanks Lutz.
Code: Select all
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
- Posts: 5289
- Joined: Thu Sep 26, 2002 4:45 pm
- Location: Pasadena, California
-
Contact:
Post
by Lutz »
Thanks Kosh, I fixed the escaped back slash:
Code: Select all
> (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/develo ... nprogress/