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.

有帮助吗?

解决方案 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.

其他提示

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

You did something else wrong.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top