Skip to main content
I am trying to update a JSON sting with new values that I am getting from API calls as part of my document automation process. the structure of the JSON is something like this: 
{"widget": {
"debug": "on",
"window": {
"title": "Sample Konfabulator Widget",
"name": "main_window",
"width": 500,
"height": 500
},
"image": {
"src": "Images/Sun.png",
"name": "sun1",
"hOffset": 250,
"vOffset": 250,
"alignment": "center"
},
"text": {
"data": "Click Here",
"size": 36,
"style": "bold",
"name": "text1",
"hOffset": 250,
"vOffset": 100,
"alignment": "center",
"onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
}
}}

 

I can use JSON get node data using widget.window.name which works fine, but if try to use JSON add node path using:

  • node path: widget.window
  • key name: new
  • value type: string
  • value: 1233445

I can get to add to the root using a path of $$, but I can find a way to add or update values deeper into the JSON string. 

As you found out, the JSON: Add node will only add to the root level of the JSON.

If you have repeating nodes, you can do some trickery with strings when looping through the repeating nodes, but in your case, there aren’t any repeating nodes.

You have a couple of options: 

  • You can use string actions to find and replace a tag with the same tag + an additional tag. 
  • You can use an Extract Text to chop the JSON apart then concatenate the string back together. 
  • You can use Python to load the JSON message into memory, make your modifications, then export the JSON back out as a string.

@Aaron.Gleason amazing. Thanks for getting back to me so quickly. I had spent hours trying to understand why it was not working. I had totally slipped on the option to string actions.

Really grateful for your help.


Reply