Welcome to Support!

Search for an answer or ask a question of the zone or Customer Support.

Need help? Dismiss Show All Questions sorted by Date Posted

Show

sorted by

Sushma  Ramakrishnan Sushma Ramakrishnan

How to Solve JSON Parser Double Quote Issue

Best Answer chosen by Sushma Ramakrishnan
Anupam Rastogi Anupam Rastogi
Hi Sushma,

Give a try with the replace method on the output that you are receiving before processing it further.

Use this method -

String transformedText = ParserOutput.replace('""', '"');

Here ParserOutput is the string that contains the output to be transformed.

Thanks

All Answers

Sagar Pareek Sagar Pareek
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"
Sushma  Ramakrishnan Sushma Ramakrishnan
Yes...
PFB my JSON Output :
"mfr_part_number_mfrpn": ""PROMINENT,
BT5B0713P"
So my issue is if I have "Double Quotes" in my Out from DB then it is throwing me exceptions like

System.JSONException: Unexpected character ('P' (code 80)): was expecting comma to separate OBJECT entries at input location
Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at input location
System.JSONException: Unexpected character ('R' (code 82)): was expecting double-quote to start field name at input location

So bacically i want some workaround to delete off the Double quote in my Output and the above should become like :
"mfr_part_number_mfrpn": "PROMINENT,
BT5B0713P"
Anupam Rastogi Anupam Rastogi
Hi Sushma,

Give a try with the replace method on the output that you are receiving before processing it further.

Use this method -

String transformedText = ParserOutput.replace('""', '"');

Here ParserOutput is the string that contains the output to be transformed.

Thanks
This was selected as the best answer
Sushma  Ramakrishnan Sushma Ramakrishnan
Hi Anupam,

Awesome my issue got solved...!
Sushma  Ramakrishnan Sushma Ramakrishnan
Thanks so much All for your help...!!!