rajh2504
rajh2504

Reputation: 1266

HTML String in JSON

I know it isn’t the best idea to have html in your JSON but sadly I am not in control of this database or this website and am not given those privileges! I am making google maps markers and one of the values is corrupting the data and not being processed right. I know the issue is in the DESC value, is there some sort of character that isn’t escaped? Because almost all of the other objects in the JSON work just fine besides this one.

{"PHONE":"847-509-2000”,
"LAT":42.15223,
"STATE":"IL”,
"ZIP":60015.0,
"NAME":"DC Sarnies”,
"DESC":"Opening in early May 2011, D.C. Sarnies is a contemporary but casual restaurant
specializing in sandwiches and classic American food with a twist. As well as a 
restaurant, we serve as a research and development kitchen for its parent company, 
Highland Baking Company. Guest chefs and bakery clients will have the opportunity to try 
out new products and let diners provide feedback on the dishes. The menu at D. C. Sarnies 
has something for everyone with a wide variety of appetizers, soups, salads, entrees and 
signature sandwiches and burgers to choose from. A full bar also gives diners a wide range 
of craft beers including more than 25 on tap, wine and cocktails. For more information 
visit us on Facebook at D.C. Sarnies or on Twitter DC_Sarnies.”,
"LONG":-87.84241,
"CITY":"Deerfield”,
"ADDR":"649 Lake Cook Road”,
"PHOTO":"DCcrabcakeburger.jpg”}]

jsonlint error message: Parse error on line 74: ...02, "DESC": "Opening in early Ma ----------------------^ Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

Upvotes: 0

Views: 1697

Answers (4)

cdeszaq
cdeszaq

Reputation: 31280

There are a couple issues:

  1. Different quotes used. is different from ".
  2. Multi-line isn't escaped. If you need the line breaks, use \n. Otherwise, just have it one line
  3. The extra ] at the end shouldn't be there

This is what you should have:

{
    "PHONE": "847-509-2000",
    "LAT": 42.15223,
    "STATE": "IL",
    "ZIP": 60015,
    "NAME": "DC Sarnies",
    "DESC": "Opening in early May 2011, D.C. Sarnies is a contemporary but casual restaurant specializing in sandwiches and classic American food with a twist. As well as a  restaurant, we serve as a research and development kitchen for its parent company,  Highland Baking Company. Guest chefs and bakery clients will have the opportunity to try  out new products and let diners provide feedback on the dishes. The menu at D. C. Sarnies  has something for everyone with a wide variety of appetizers, soups, salads, entrees and  signature sandwiches and burgers to choose from. A full bar also gives diners a wide range  of craft beers including more than 25 on tap, wine and cocktails. For more information  visit us on Facebook at D.C. Sarnies or on Twitter DC_Sarnies.",
    "LONG": -87.84241,
    "CITY": "Deerfield",
    "ADDR": "649 Lake Cook Road",
    "PHOTO": "DCcrabcakeburger.jpg"
}

Upvotes: 1

AbhiRoczz...
AbhiRoczz...

Reputation: 252

End double quotes wrong. Rest everything is fine and working.

Upvotes: 2

fivedigit
fivedigit

Reputation: 18672

http://jsonlint.org/ use this website to validate your JSON.

The problem here are the closing quotes you use for strings, they're invalid.

Upvotes: 3

Rudolph Gottesheim
Rudolph Gottesheim

Reputation: 1701

The double quotes at the end of the values are the problem. They're the wrong character.

Upvotes: 1

Related Questions