JSON parse error

811 views
Skip to first unread message

Daniel Kantor

unread,
Jun 7, 2010, 12:12:17 PM6/7/10
to Chromium HTML5
I am getting this error back sometimes when I call JSON.parse - 

SyntaxError: Unexpected token ILLEGAL

The JSON was created using JSON.stringify. Any idea why this could be happening?

thanks,
Dan

PhistucK

unread,
Jun 7, 2010, 1:04:21 PM6/7/10
to Daniel Kantor, Chromium HTML5
If you could give a reproducible example - that will help us investigate.

☆PhistucK


--
You received this message because you are subscribed to the Google Groups "Chromium HTML5" group.
To post to this group, send email to chromiu...@chromium.org.
To unsubscribe from this group, send email to chromium-html...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-html5/?hl=en.

Arne Roomann-Kurrik

unread,
Jun 7, 2010, 1:29:21 PM6/7/10
to phis...@chromium.org, Daniel Kantor, Chromium HTML5
I believe I've gotten this from malformed JSON in the past - if you could provide a string that causes the error it would really help.

~Arne

Daniel Kantor

unread,
Jun 7, 2010, 2:22:11 PM6/7/10
to kur...@chromium.org, phis...@chromium.org, Chromium HTML5
rather large, but here is an example of JSON throwing that error - 


This was an object returned from the SQLite DB then stringified. 

thanks,
Dan
--
Dan Kantor
Founder / CEO ExtensionFM
http://www.extension.fm
m: 516.298.2969

Arne Roomann-Kurrik

unread,
Jun 7, 2010, 2:24:01 PM6/7/10
to Daniel Kantor, phis...@chromium.org, Chromium HTML5
Looks like there's some sort of issue with that feed - it ends in 

"domain"%3
Which appears to be truncated somehow.

~Arne

Daniel Kantor

unread,
Jun 7, 2010, 2:31:31 PM6/7/10
to kur...@chromium.org, phis...@chromium.org, Chromium HTML5
Yeah, I see that too. All I did was call JSON.stringify on the object. Should that throw an error if the object didn't stringify properly?

Arne Roomann-Kurrik

unread,
Jun 7, 2010, 2:38:23 PM6/7/10
to Daniel Kantor, phis...@chromium.org, Chromium HTML5
Not sure, which serverside library are you using?

~Arne

Daniel Kantor

unread,
Jun 7, 2010, 2:46:54 PM6/7/10
to kur...@chromium.org, phis...@chromium.org, Chromium HTML5
All done in Chrome javascript. Data is coming from HTML5 Web DB. 

Arne Roomann-Kurrik

unread,
Jun 7, 2010, 2:58:57 PM6/7/10
to Daniel Kantor, phis...@chromium.org, Chromium HTML5
In that case I'm not really sure.  All output from V8's JSON.stringify should be able to go into JSON.parse successfully.  How did you get the string you hosted?  If you used the Chromium Dev Tools it's possible that the string was truncated when you copied /pasted it - I doubt that JSON.stringify would just return a partial string like that.

Does the parse call work with a smaller set of data?  Does this only happen when the data set is very large?

~Arne

Daniel Kantor

unread,
Jun 7, 2010, 3:15:22 PM6/7/10
to kur...@chromium.org, phis...@chromium.org, Chromium HTML5
I send the string up to PHP as a POST. PHP does GZIP it before sending it to S3.

That library is on my home computer. Tonight when I get home, I will try logging it to the console to see if it is getting truncated in the transmission. 

Dan

Arne Roomann-Kurrik

unread,
Jun 7, 2010, 3:24:08 PM6/7/10
to Daniel Kantor, phis...@chromium.org, Chromium HTML5
Yeah, that would be useful.  Please follow up with the request details.  

~Arne

Max

unread,
Jun 7, 2010, 2:21:40 PM6/7/10
to Chromium HTML5
Chrome 4 allowed using single instead of double quotes in
JSON.parse(), while Chrome 5 doesn't. If all your strings are from
Chrome's JSON.stringify(), this shouldn't apply, but it's worth to
check just in case.

On Jun 7, 11:29 am, Arne Roomann-Kurrik <kur...@chromium.org> wrote:
> I believe I've gotten this from malformed JSON in the past - if you could
> provide a string that causes the error it would really help.
>
> ~Arne
>
>
>
> On Mon, Jun 7, 2010 at 1:04 PM, PhistucK <phist...@chromium.org> wrote:
> > If you could give a reproducible example - that will help us investigate.
>
> > ☆PhistucK
>
> > On Mon, Jun 7, 2010 at 19:12, Daniel Kantor <dan.kan...@gmail.com> wrote:
>
> >> I am getting this error back sometimes when I call JSON.parse -
>
> >> SyntaxError: Unexpected token ILLEGAL
>
> >> The JSON was created using JSON.stringify. Any idea why this could be
> >> happening?
>
> >> thanks,
> >> Dan
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Chromium HTML5" group.
> >> To post to this group, send email to chromium-ht...@chromium.org.
> >> To unsubscribe from this group, send email to
> >> chromium-html5+unsubscr...@chromium.org<chromium-html5%2Bunsubscr...@chromium.org>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/a/chromium.org/group/chromium-html5/?hl=en.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Chromium HTML5" group.
> > To post to this group, send email to chromium-ht...@chromium.org.
> > To unsubscribe from this group, send email to
> > chromium-html5+unsubscr...@chromium.org<chromium-html5%2Bunsubscr...@chromium.org>
> > .

Daniel Kantor

unread,
Jun 8, 2010, 12:23:50 PM6/8/10
to Max, Chromium HTML5
I wasn't able to get to my data since it is in the released extension as opposed to the unpacked one. I will try and replicate this though in the unpacked one. Will update here when I have it. 

Dan

To post to this group, send email to chromiu...@chromium.org.
To unsubscribe from this group, send email to chromium-html...@chromium.org.



--

harpreet singh

unread,
Mar 25, 2014, 1:39:16 PM3/25/14
to chromiu...@chromium.org, Max
I think I know the problem.

var str = JSON.stringify(object) is adding \\n in the string and JSON.parse(str) does not give the same object back.

As a result this becomes a problem when the object has some attributes encoded in let say base 64.

harpreet singh

unread,
Mar 25, 2014, 1:43:47 PM3/25/14
to chromiu...@chromium.org, Max
I think I know the problem.

var str = JSON.stringify(object) is adding \\n in the string and JSON.parse(str) does not give the same object back.

As a result this becomes a problem when the object has some attributes encoded in let say base 64.



On Tuesday, 8 June 2010 21:53:50 UTC+5:30, dankantor wrote:
Reply all
Reply to author
Forward
0 new messages