2012-01-06 61 views
0

我知道這是不是有HTML在你的JSON最好的想法,但可悲的是,我沒有在這個數據庫或本網站的控制,我不給這些特權!我正在製作Google地圖標記,其中一個值正在破壞數據並且未被正確處理。我知道這個問題出現在DESC值中,有沒有逃脫的某種角色?因爲除了這個之外,幾乎所有JSON中的其他對象都可以正常工作。HTML字符串的JSON

{"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錯誤消息:解析錯誤74行: ...... 02, 「DESC」:「開幕式在馬早期 --------------- -------^ 期望'STRING','NUMBER','NULL','TRUE','FALSE','{','['

+0

另外,我不認爲在諸如任何HTML,只是文本和其他「正常」的數據。那裏的HTML在哪裏? – cdeszaq 2012-01-06 17:47:35

+0

試圖引號沒有去 – rajh2504 2012-01-06 17:54:24

+0

一些對象確實有HTML,但是這是它崩潰 – rajh2504 2012-01-06 17:58:06

回答

3

http://jsonlint.org/使用此網站驗證您的JSON

這裏的問題是,你使用字符串收盤報價,他們是無效的。

+0

引號problemn後,你還必須確保在DESC屬性中刪除或替換換行符的對象。 – fivedigit 2012-01-06 17:55:40

+0

我添加了從JSON lint獲得的錯誤,我很困惑,因爲它是一個實際的字符串,所以爲什麼解析會相信? – rajh2504 2012-01-06 18:10:27

+0

字符串內部存在換行符,導致JSON無效。您需要將其刪除,或者用'\ N' – fivedigit 2012-01-06 18:15:13

1

在值末尾的雙引號是錯誤的字符

1

有幾個問題:使用

  1. 不同的報價。 "不同。
  2. 多行不逃脫。如果您需要換行符,請使用\n。否則,只是它在最後一行
  3. 額外]不應該存在

這是你應該什麼:

{ 
    "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" 
} 
2

結束雙引號錯誤。休息一切都很好,工作。