<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Survey123 JSON format issues... in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/survey123-json-format-issues/m-p/1261221#M66927</link>
    <description>&lt;P&gt;As ESRI product, using malformed JSON? Say it ain't so! Anyways, I did some digging and the&amp;nbsp;&lt;A href="https://pypi.org/project/demjson/" target="_blank" rel="noopener"&gt;demjson&lt;/A&gt;&amp;nbsp;package comes up a bunch, I'd say that's your best bet short of building your own parser library.&lt;/P&gt;</description>
    <pubDate>Fri, 24 Feb 2023 00:09:02 GMT</pubDate>
    <dc:creator>DavidSolari</dc:creator>
    <dc:date>2023-02-24T00:09:02Z</dc:date>
    <item>
      <title>Survey123 JSON format issues...</title>
      <link>https://community.esri.com/t5/python-questions/survey123-json-format-issues/m-p/1261207#M66926</link>
      <description>&lt;P&gt;Asked the following question in the Survey123 community, but thinking it might be a Python issue and that I'm just not looking at things correctly...&lt;BR /&gt;---&lt;/P&gt;&lt;P&gt;This is a super nitpicky question, so apologies in advance.&lt;/P&gt;&lt;P&gt;It seems like most times I deal with JSON, it conforms to the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://www.ecma-international.org/wp-content/uploads/ECMA-404_2nd_edition_december_2017.pdf" target="_blank" rel="noopener nofollow noreferrer"&gt;ECMA spec&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;which states that strings must be contained with the double-quote character ("). However, most (not all!), of the info I get in JSON from Survey123 is in single quotes. This gets weirder if the said string contains a single quote, as then the entire string gets placed in double-quotes, per the spec, while every other string remains in single-quotes.&lt;/P&gt;&lt;P&gt;By way of example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  'full_name': "Roger O'Leary", 
  'email_address': 'rolo@sample.com'
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Programmatically, depending on what I'm doing with said data, I will get an error such as:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Expecting property name enclosed in double quotes: line 2 column 3&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Obviously this can be fixed by running some validation, replacing single quotes with double quotes, and escaping legit single-quotes. But I'm curious if there's a better way (in Python at the moment...) or if I'm not retrieving the JSON from the webhook properly to begin with (in azure function app with req.get_json() example below)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import logging
import azure.functions as func

def main(req: func.HttpRequest) -&amp;gt; func.HttpResponse:
    jsonString = req.get_json()
    logging.error(f"The json is: {jsonString}")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Full JSON example below (raw, unformatted as received):&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;{'applyEdits': [{'id': 0, 'adds': [{'attributes': {'problem_type_ordered_by_most_co': 'Road Problem', 'land_use_problems_type': None, 'describe_the_problem': 'Feb. 23 Roads test.', 'address': '1200-1298 Hayes Ave, Fairbanks, Alaska, 99709', 'full_name': "Roger O'Leary", 'email_address': 'rolo@urbanraven.com', 'globalid': '{603034E6-6360-41D2-88D1-B4F7D11C97B5}'}, 'geometry': {'geometryType': 'esriGeometryPoint', 'x': -147.80548593192015, 'y': 64.8548894970469, 'spatialReference': {'wkid': 4326}}}], 'attachments': {'adds': [{'globalId': '{1D9FB73D-E791-4C56-888D-A0C583CC45F9}', 'parentGlobalId': '{603034E6-6360-41D2-88D1-B4F7D11C97B5}', 'keywords': 'if_availale_add_photo', 'contentType': 'image/jpeg', 'name': 'Ridgepoint+ditching.jpg', 'uploadId': 'df6ade0f739a4999b6bb29323dd13f12'}]}}], 'feature': {'attributes': {'problem_type_ordered_by_most_co': 'Road Problem', 'land_use_problems_type': None, 'describe_the_problem': 'Feb. 23 Roads test.', 'location_of_problemDefault': None, 'location_of_problemRoads': {'geometryType': 'esriGeometryPoint', 'x': -147.80548593192015, 'y': 64.8548894970469, 'spatialReference': {'wkid': 4326}}, 'location_of_problemTransfer': None, 'location_of_problemTransport': None, 'location_of_problemParks': None, 'location_of_problemWater': None, 'address': '1200-1298 Hayes Ave, Fairbanks, Alaska, 99709', 'full_name': "Roger O'Leary", 'email_address': 'rolo@urbanraven.com', 'globalid': '{603034E6-6360-41D2-88D1-B4F7D11C97B5}', 'objectid': 430}, 'geometry': {'geometryType': 'esriGeometryPoint', 'x': -147.80548593192015, 'y': 64.8548894970469, 'spatialReference': {'wkid': 4326}}, 'layerInfo': {'id': 0, 'name': 'survey', 'type': 'Feature Layer', 'globalIdField': 'globalid', 'objectIdField': 'objectid', 'relationships': []}, 'result': {'globalId': '{603034E6-6360-41D2-88D1-B4F7D11C97B5}', 'objectId': 430, 'uniqueId': 430, 'success': True}, 'attachments': {'if_availale_add_photo': [{'id': 145, 'url': '&lt;A href="https://services.arcgis.com/f4rR7WnIfGBdVYFd/arcgis/rest/services/survey123_c7daf2da3e0e488abbd0bf527bd602e5_fieldworker/FeatureServer/0/430/attachments/145" target="_blank" rel="nofollow noopener noreferrer"&gt;https://services.arcgis.com/f4rR7WnIfGBdVYFd/arcgis/rest/services/survey123_c7daf2da3e0e488abbd0bf52...&lt;/A&gt;', 'name': 'Ridgepoint+ditching.jpg', 'size': 886497, 'contentType': 'image/jpeg', 'keywords': 'if_availale_add_photo', 'globalId': '{1D9FB73D-E791-4C56-888D-A0C583CC45F9}', 'parentGlobalId': '{603034E6-6360-41D2-88D1-B4F7D11C97B5}'}]}}, 'eventType': 'addData'}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 23 Feb 2023 23:34:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/survey123-json-format-issues/m-p/1261207#M66926</guid>
      <dc:creator>RogerAsbury</dc:creator>
      <dc:date>2023-02-23T23:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: Survey123 JSON format issues...</title>
      <link>https://community.esri.com/t5/python-questions/survey123-json-format-issues/m-p/1261221#M66927</link>
      <description>&lt;P&gt;As ESRI product, using malformed JSON? Say it ain't so! Anyways, I did some digging and the&amp;nbsp;&lt;A href="https://pypi.org/project/demjson/" target="_blank" rel="noopener"&gt;demjson&lt;/A&gt;&amp;nbsp;package comes up a bunch, I'd say that's your best bet short of building your own parser library.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 00:09:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/survey123-json-format-issues/m-p/1261221#M66927</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2023-02-24T00:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: Survey123 JSON format issues...</title>
      <link>https://community.esri.com/t5/python-questions/survey123-json-format-issues/m-p/1261280#M66933</link>
      <description>&lt;P&gt;Had not heard of that particular package. Will give it a look. Thanks much!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 02:09:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/survey123-json-format-issues/m-p/1261280#M66933</guid>
      <dc:creator>RogerAsbury</dc:creator>
      <dc:date>2023-02-24T02:09:15Z</dc:date>
    </item>
  </channel>
</rss>

