سؤال

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