Question

This piece of JSON right here:

{"user":[{"idUser":"1","username":"USERNAME","userFullName":"FULL NAME","userEmail":"EMAIL@MAIL.COM"}]}

Does not validate in jsonlint also not with GWT.

What is strange is that if I delete the first curly brace and type it again, it returns as valid. Here is the error it gives:

Parse error on line 1:
{    "user": [   
^
Expecting '{', '['

Any reason for this? Note that I'm using PHP to generate this string. PHP file used is UTF-8 encoded.

Was it helpful?

Solution 2

Thanks to @knittl for noticing it.

I had the php file encoded in UTF-8.

I changed it to UTF-8 without BOM and it worked. I suppose some "garbage" was being returned when I was copying it to jsonlint.

OTHER TIPS

When I copy/paste that into JSONLint, it passes.

You did something else wrong.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top