Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Why does XML to JSON insert a backslash in front of my forward slash and how can I stop it?

Not applicable

Input XML fragment:

<organizationStateParty>Acme (ME / 74)</organizationStateParty>

Resultant JSON:

"organizationStateParty":"Acme (ME \/ 74)"

Online tools don't do it.

Also, what are the valid values for the Format property on this policy? It's not documented and its just a string in the Schema.

Thanks, Kurt

Solved Solved
1 3 32.9K
1 ACCEPTED SOLUTION

Dear @Kurt Kanaskie ,

Those backslashes are escape characters. They are escaping the special characters inside of the string associated with JSON response.

You have to use JSON.parse to parse that JSON string into a JSON object.

For example, below url will have backward slashes if it's a raw JSON string. The same url if you convert into object using JSON.parse or install chrome browser plugin like JSON viewer you will never see them.

754-screen-shot-2015-07-13-at-101144-pm.png

753-screen-shot-2015-07-13-at-101130-pm.png

Cheers,

Anil Sagar

View solution in original post

3 REPLIES 3