Skip to main content
Solved

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

  • June 2, 2021
  • 3 replies
  • 229 views

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.

Best answer by debbiatsafe

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?

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

debbiatsafe
Safer
Forum|alt.badge.img+21
  • Safer
  • 648 replies
  • Best Answer
  • June 2, 2021

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?


  • Author
  • 1 reply
  • June 2, 2021

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.


debbiatsafe
Safer
Forum|alt.badge.img+21
  • Safer
  • 648 replies
  • June 3, 2021

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.