0

I am creating a JSON which contains the encoded Hindi language data. The font is AAText. The text coming in the json is ' and \ which throwing error when trying to validating the JSON. Here \ is used as ? in Hindi language. Example is below

{ "BhagwanList": [   { "BhagwanId": "1","BhagwanName": "Jain Maharaj", "QuestionList": [ { "questionId": "26", "questionText": "bUnzHkwfr xkSre fdrus HkkbZ Fks \",  "ansText": "'rhu&(bUnzHkwfrxkSre ]vfxzHkwfrvkSjok;qHkwfr)",  "other": "oS'kkyh"} ]   } ]}

I have already tried using the \ to escape the character but it does not work. Could anyone suggest how I can use ' and \ in the JSON.

Richard Chambers
  • 16,643
  • 4
  • 81
  • 106
Alex
  • 93
  • 6
  • In the example you gave you escaped the wrong ". You escaped the closing " of the value. – Igal S. Jun 07 '15 at 12:56
  • Here \ in the "bUnzHkwfr xkSre fdrus HkkbZ Fks \" is creating the problem. If you decode it using AAText in notepad then \ denote ?. Similar ' in the "oS'kkyh" – Alex Jun 07 '15 at 13:01
  • This sounds like a character encoding issue and the two characters `'` and `\\` should really be the encoded Hindi characters. See the following stack overflow questions and their answers http://stackoverflow.com/questions/3995559/json-character-encoding and http://stackoverflow.com/questions/583562/json-character-encoding-is-utf-8-well-supported-by-browsers-or-should-i-use-nu and http://stackoverflow.com/questions/9254891/what-does-content-type-application-json-charset-utf-8-really-mean – Richard Chambers Jun 07 '15 at 13:01
  • Can I make a valid JSON using ' and \? – Alex Jun 07 '15 at 13:49
  • Please update your question with specifics as to the actual application environment. If this is some kind of a web service, what you really want to do is to have a valid JSON text with Hindi language using UTF-8 encoding and then specify the charset as UTF-8 for the download. The characters ' and \ are valid JSON characters however they have special meanings wiithin a JSON text string. I suspect you need to forget about the specific characters of ' and \ and instead concentrate on how to use UTF-8 to encode Hindi. – Richard Chambers Jun 07 '15 at 15:23

0 Answers0