json-parse with inner double quote

Featuring the Dragonfly web framework

json-parse with inner double quote

Postby kosh » Thu Jun 20, 2013 11:56 am

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
kosh
 
Posts: 68
Joined: Sun Sep 13, 2009 5:38 am
Location: Japan

Re: json-parse with inner double quote

Postby Lutz » Thu Jun 20, 2013 3:16 pm

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
Lutz
 
Posts: 5258
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: json-parse with inner double quote

Postby kosh » Fri Jun 28, 2013 12:39 pm

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.
kosh
 
Posts: 68
Joined: Sun Sep 13, 2009 5:38 am
Location: Japan

Re: json-parse with inner double quote

Postby Lutz » Fri Jun 28, 2013 2:37 pm

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/
Lutz
 
Posts: 5258
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California


Return to So, what can you actually DO with newLISP?

Who is online

Users browsing this forum: No registered users and 2 guests