1

We have an issue in passing JSON , the value contains double quotes and we are getting error

"searchResultsDetails":[
{
"compannyName":""schiing" Immobien & Co Lingasse KG",
"testId":77472,
}
]

You can see that the compannyName contains double quotes in the value.

var data= $.parseJSON(modelAttr); 

modelattr is the above JSON string,

when I try this jquery method, I am getting parsing error, how we can parse double quotes and special characters, please help

Regards Hari

vahid abdi
  • 9,636
  • 4
  • 29
  • 35
user2907217
  • 137
  • 2
  • 13

1 Answers1

3

To write special characters in a string you have to escape them, using the backslash character \.

So your example would look like this:

"compannyName":"\"schiing\" Immobien & Co Lingasse KG"

Sascha Wolf
  • 18,810
  • 4
  • 51
  • 73
  • Could you please tell me how we can achieve this in Javascript/jquery – user2907217 Feb 25 '14 at 07:56
  • 1
    Where are you getting the JSON values from? – Sascha Wolf Feb 25 '14 at 07:57
  • Try this http://stackoverflow.com/questions/2732409/how-can-i-put-double-quotes-inside-a-string-within-an-ajax-json-response-from-ph ........................ http://stackoverflow.com/questions/21070173/android-parsing-json-string-inside-of-double-quotes ....... http://www.2ality.com/2012/09/javascript-quotes.html – Hitesh Feb 25 '14 at 09:01