Cercando di analizzare una stringa JSON, ma non ci riesce sempre
Domanda
Questo pezzo di JSON proprio qui:
{"user":[{"idUser":"1","username":"USERNAME","userFullName":"FULL NAME","userEmail":"EMAIL@MAIL.COM"}]}
non convalida in jsonlint anche non con GWT.
Quello che è strano è che se si elimina la prima parentesi graffa e digitarla nuovamente, restituisce come valido. Ecco l'errore dà:
Parse error on line 1:
{ "user": [
^
Expecting '{', '['
Qual è il motivo di questo? Si noti che sto usando il PHP per generare questa stringa. file PHP usato è UTF-8 codificato.
Soluzione 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.
Altri suggerimenti
When I copy/paste that into JSONLint, it passes.
You did something else wrong.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow