Escape in JSON For Quotation Mark

3158
10
03-13-2019 11:26 AM
joerodmey
MVP Alum

I want to pass a quotation mark into JSON but the escape methods I'm using don't appear to be working. How do you pass a strong into JSON with a quotation mark?

[

    {
        "attributes": {
            "OBJECTID": 307,
            "Comments": "This is a test "with quotes""
        }
    }

]

0 Kudos
10 Replies
RandyBurton
MVP Alum

I would try \" :

[
    {
        "attributes": {
            "OBJECTID": 307,
            "Comments": "This is a test \"with quotes\""
        }
    }
]
0 Kudos
joerodmey
MVP Alum

Didn't work. I'm using Integromat push this JSON. Integromat has dynamic data modules that are passed in...don't know if this is causing the issue.

Also, not every time the user will enter quotes in the text box.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

If escaping isn't working, I would try raw string formatting or triple-quoted literals.

0 Kudos
joerodmey
MVP Alum

Already have Integromat set to RAW body type

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

For your example, I am talking about Python raw strings or triple-quotes:

>>> print(r'This is a test "with quotes"')
This is a test "with quotes"
>>> print('''This is a test "with quotes"''')
This is a test "with quotes"
>>>
0 Kudos
joerodmey
MVP Alum

I'm using JSON

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Apologies, I thought this was posted in ArcGIS API for Python‌, not ArcGIS REST API

0 Kudos
JoshuaBixby
MVP Esteemed Contributor
0 Kudos
RandyBurton
MVP Alum

The text appearing in the "Value" window  doesn't look like well formed JSON.  It looks like it is a paste inside a previous paste.  If you want "feature" inside the window, it should be in quotes as should "attributes" along with some commas in there.  I would also suspect that the Name should be "features" not "updates".   I must admit, however, that I am not very familiar with Integromat.  To check your JSON, try jsonlint.

0 Kudos