Skip to main content
Question

Parse ESRI Json file output, add new static variable, then rewrite back to Json file with new variable


Hello,

I have a few ESRI generated json response files from ArcGIS Server feature service that can contain 1 to 200 records per response and these do not have geometry.

 

What I want to accomplish is to add one new parameter "projectnumber" and assign it with a static variable and rewrite the output back to JSON or ESRI JSON file again.

 

Thanks in advance !

 

Original:

{

  "attributes": {

  "sapfloctplnr": "MASG-GASD-SA01-SERL-0055647",

  "lifecyclestatus": 1,

  "GLOBALID": "{E839E029-529F-4D6B-9C4E-85BD875BC582}",

  "ASSETGROUP": 1

  }

 },

 {

  "attributes": {

  "sapfloctplnr": "MASG-GASD-SA01-SERL-0055649",

  "lifecyclestatus": 1,

  "GLOBALID": "{A9BF1A40-C1E4-4BC7-A538-7011FA9C55EA}",

  "ASSETGROUP": 1

  }

 },

 {

  "attributes": {

  "sapfloctplnr": "MASG-GASD-SA01-SERL-0055659",

  "lifecyclestatus": 1,

  "GLOBALID": "{2C931767-555B-44CB-B8B0-EFD345FCD324}",

  "ASSETGROUP": 1

  }

 }

 

Desired output:

 

{

  "attributes": {

  "sapfloctplnr": "MASG-GASD-SA01-SERL-0055647",

  "lifecyclestatus": 1,

  "GLOBALID": "{E839E029-529F-4D6B-9C4E-85BD875BC582}",

  "ASSETGROUP": 1,

"projectnumber": :123abc"

  }

 },

 {

  "attributes": {

  "sapfloctplnr": "MASG-GASD-SA01-SERL-0055649",

  "lifecyclestatus": 1,

  "GLOBALID": "{A9BF1A40-C1E4-4BC7-A538-7011FA9C55EA}",

  "ASSETGROUP": 1,

"projectnumber": :123abc"

  }

 },

 {

  "attributes": {

  "sapfloctplnr": "MASG-GASD-SA01-SERL-0055659",

  "lifecyclestatus": 1,

  "GLOBALID": "{2C931767-555B-44CB-B8B0-EFD345FCD324}",

  "ASSETGROUP": 1,

"projectnumber": :123abc"

  }

 }

3 replies

daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • October 14, 2021

Hi @litung8​,

You can use a JSONFragmenter to split up the source JSON into features. Set Flatten Query Result into attributes to Yes to extract the JSON info as attributes. Then use the JSONTemplater to build the new JSON, including the Project Number. I am attaching a workspace to illustrate.


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • October 15, 2021

You should also be able to use a JSONUpdater to do this


  • Author
  • October 15, 2021
daveatsafe wrote:

Hi @litung8​,

You can use a JSONFragmenter to split up the source JSON into features. Set Flatten Query Result into attributes to Yes to extract the JSON info as attributes. Then use the JSONTemplater to build the new JSON, including the Project Number. I am attaching a workspace to illustrate.

Thank you @daveatsafe​  This works great ! I spent many hours trying to get this output - you saved the day :)


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings