0

the following bit of JSON code is seen as invalid in two independent validators (but I have a suspicion that some validators would accept it). Since I know very little about JSON, could anybody please point out the mistake?

{
     "cz": "CZ 51740018",
     "bod_id": "30476",
     "N": "",
     "E": "",
     "nazev": "ICE\'N\'GO\! CZ s.r.o.", // <-- this line probably has a mistake
     "adresa": "Pražská 2116/12a, 46601 Jablonec nad Nisou",
     "ddata": "",
     "typ_id": "0",
     "zdroj": ""
}
Timothy Groote
  • 8,614
  • 26
  • 52

2 Answers2

0

JSLint tells me the backslashes are the problem (like ggzone said)

{
    "cz" : "CZ 51740018",
    "bod_id" : "30476",
    "N" : "",
    "E" : "",
    "nazev" : "ICE'N'GO! CZ s.r.o.", // <-- fixed the mistake
    "adresa" : "Pražská 2116/12a, 46601 Jablonec nad Nisou",
    "ddata" : "",
    "typ_id" : "0",
    "zdroj" : ""
}

If you need to keep the escaped special characters in place, you might try double escaping them like this :

{
    "nazev" : "ICE\\'N\\'GO\\! CZ s.r.o.", // <-- this is fine too.
}
Timothy Groote
  • 8,614
  • 26
  • 52
0

The problem is actually in the bold text. Are you trying to escape a single quote? If that's what you are trying to do, you don't have to escape single quotation in JSON just remove the backslashes and it should be correct. check this out jQuery single quote in JSON response

Community
  • 1
  • 1