Solved

How to transform JSON file from Esri Extract Changes API call back into features I can write to another hosted feature service.


I'm trying to build an archive off a feature service hosted in ArcGIS Online by getting the changes and writing them to a second hosted feature service.

 

I can get the changes in JSON, but I'm struggling to turn them back into usable features.

 

The format looks like this:

 

"edits" : [
      {
         "id" : 0,
         "features" : {
            "adds" : [
               {
                  "geometry" : {
                     "x" : -119.58448584499996,
                     "y" : 32.10688862600006
                  },
                  "attributes" : {
                     "OBJECTID" : 93,
                     "GlobalID" : "1DF7CAF6-D3CC-4E8D-8FB3-C6714C06890A",
                     "IncidentName" : "Testing",
                     "Label" : "DIV X",
                     "Label2" : null,
                     "LabelType" : "Division",
                     "Other" : null,
                     "CreateName" : "test_nifc",
                     "CreateDate" : 1621322205148,
                     "EditName" : "test_nifc",
                     "DateCurrent" : 1621322205148,
                     "IRWINID" : null,
                     "FeatureAccess" : "Cooperators",
                     "FeatureStatus" : "Approved",
                     "IsVisible" : "Yes"
                  }
               },
               {
                  "geometry" : {
                     "x" : -119.59246936699998,
                     "y" : 32.08059610300006
                  },
                  "attributes" : {
                     "OBJECTID" : 91,
                     "GlobalID" : "463ABC0E-BB06-49D0-AA82-7FD1FA037141",

 

Using the JSON Reader I can set queries for each layer's "adds" and "updates" but that just returns one features with the attributes for all those features in it.

 

Any guidance would be greatly appreciated. I have been unsuccessful in adapting any of the examples I've found for parsing JSON.

icon

Best answer by debbiatsafe 3 June 2021, 00:53

View original

3 replies

Userlevel 3
Badge +17

Hi @walker_henry​ 

If you're seeing only feature output for each layer, then I suspect you may not be fragmenting the adds/updates array. What queries are you using in the JSON reader? Are you able to try this query: json[*]["features"]["adds"][*] for the adds layer?

Hi @walker_henry​ 

If you're seeing only feature output for each layer, then I suspect you may not be fragmenting the adds/updates array. What queries are you using in the JSON reader? Are you able to try this query: json[*]["features"]["adds"][*] for the adds layer?

Ooohhhhh!

That was it. I was using JSON["edits"][0]["features"]["adds"]

Thanks!

 

Is this the best way to parse JSON into features?

Having to do all the separate queries and then process the geometry make me feels like I'm missing something.

Userlevel 3
Badge +17

Ooohhhhh!

That was it. I was using JSON["edits"][0]["features"]["adds"]

Thanks!

 

Is this the best way to parse JSON into features?

Having to do all the separate queries and then process the geometry make me feels like I'm missing something.

Hi @walker_henry​ 

Theoretically, you could use json[*]["features"][*][*] in the JSON reader but then you would lose the edit type information (ie. adds, updates, deletes) on the resulting features.

 

Unfortunately, it looks like the geometry isn't formatted in the GeoJSON or Esri GeoJSON format so it cannot be automatically parsed using the respective readers.

Reply