<?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 Is Survey123 webhook sending valid JSON? in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/is-survey123-webhook-sending-valid-json/m-p/1261149#M47622</link>
    <description>&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;A href="https://www.ecma-international.org/wp-content/uploads/ECMA-404_2nd_edition_december_2017.pdf" target="_blank" rel="noopener"&gt;ECMA spec&lt;/A&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;LI-CODE lang="c"&gt;{
  'full_name': "Roger O'Leary", 
  'email_address': 'rolo@sample.com'
}&lt;/LI-CODE&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;LI-CODE lang="python"&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;/LI-CODE&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"&gt;https://services.arcgis.com/f4rR7WnIfGBdVYFd/arcgis/rest/services/survey123_c7daf2da3e0e488abbd0bf527bd602e5_fieldworker/FeatureServer/0/430/attachments/145&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Feb 2023 22:40:30 GMT</pubDate>
    <dc:creator>RogerAsbury</dc:creator>
    <dc:date>2023-02-23T22:40:30Z</dc:date>
    <item>
      <title>Is Survey123 webhook sending valid JSON?</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/is-survey123-webhook-sending-valid-json/m-p/1261149#M47622</link>
      <description>&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;A href="https://www.ecma-international.org/wp-content/uploads/ECMA-404_2nd_edition_december_2017.pdf" target="_blank" rel="noopener"&gt;ECMA spec&lt;/A&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;LI-CODE lang="c"&gt;{
  'full_name': "Roger O'Leary", 
  'email_address': 'rolo@sample.com'
}&lt;/LI-CODE&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;LI-CODE lang="python"&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;/LI-CODE&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"&gt;https://services.arcgis.com/f4rR7WnIfGBdVYFd/arcgis/rest/services/survey123_c7daf2da3e0e488abbd0bf527bd602e5_fieldworker/FeatureServer/0/430/attachments/145&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 22:40:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/is-survey123-webhook-sending-valid-json/m-p/1261149#M47622</guid>
      <dc:creator>RogerAsbury</dc:creator>
      <dc:date>2023-02-23T22:40:30Z</dc:date>
    </item>
  </channel>
</rss>

