Join the Stack Overflow Community
Stack Overflow is a community of 6.5 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I'm trying to parse a JSON string : ( with JSON.parse() )

[{"number":0}]

But it shows me the message : SyntaxError: Unexpected token { at Object.parse (native) http://img4.hostingpics.net/pics/789845screengladys.png

My JSON seems to be correct, does everyone have an ideas how to fix it ? Thank you in forward for your help :)

share|improve this question
    
It looks like the error is on [, not {. There must be something before that character that is causing it to be invalid. – Sean Fujiwara May 8 '14 at 16:58
    
the json string comes from an ajax request with xmlhttprequest, but when I output the string, I have nothing before [, just the json ! img15.hostingpics.net/pics/896329alarme.png – user3374466 May 8 '14 at 17:10
    
Are you using the right function? The stack trace says Object.parse, but you should be using JSON.parse. – Sean Fujiwara May 8 '14 at 23:18
    
Yes i'm sure! here is my code : if (xhralarme.readyState == 4 && xhralarme.status == 200) { alarmes = JSON.parse(xhralarme.responseText); } – user3374466 May 9 '14 at 5:31
1  
Hmm, do typeof(xhralarme.responseText) and xhralarme.responseText.length give the values you expect? – Sean Fujiwara May 9 '14 at 19:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.