Question

Modifying a nested attribute value with JSONUpdater

  • 7 January 2022
  • 4 replies
  • 18 views

Hi, I'm looking to update a value of an existing JSON structure once it has already been constructed.

I feel I'm using JSONUpdater for its correct purpose, but might be messing up the syntax. Attached is how it looks for me:

Screenshot 2022-01-07 141455Does this appear to be the correct syntax for trying to modifying a nested key/value pair?

I also wonder if using the attribute "ProgramProfile" for the JSON Text field would be a better approach, as it does show up in the list of selectable attributes. I have not had luck with this approach either though.

 

JSON sample being used:

{
   "UserInfoList" : [
      {
         "IntegrationUserID" : "123456789",
         "UserProfile" : {
            "FirstName" : "Johnny"
         },
         "ProgramProfile" : {
            "UserCategoryName" : "PLACEHOLDER"
         },
         "AddressProfileList" : [
            {
               "CountryName" : "Japan"
            }
         ]
      }
   ]
}

 


4 replies

Userlevel 2
Badge +17

Hi @steve.mohawk​ , I don't think you should quote the Object/Array Index.

 

"Object/Array Index

This parameter is used to specify the specific object key / array index whose value is to be inserted/removed/modified.

For object updates, this value of this parameter should be a string, which will be interpreted as an object key. Quotes are NOT required around the string in this parameter."

-- JSONUpdater Help

Hi, unfortunately changing the Object/Array Index to not include the quotes did not seem to have any effect.

Does my approach seem to be on the right track, or should I be looking at a different transformer in this case?

Userlevel 2
Badge +17

Hi, unfortunately changing the Object/Array Index to not include the quotes did not seem to have any effect.

Does my approach seem to be on the right track, or should I be looking at a different transformer in this case?

I believe you are on the right track , but I'm just afraid that you have input no feature into the Update port.

 

The JSONUpdater always requires receiving a feature from the Update port, even if you don't need to use any attribute values from the Update feature.

If you have input no feature into the Update port, try adding a Creator and connect it to the port, like the screenshot attached. jsonupdater-with-creator

I believe you are on the right track , but I'm just afraid that you have input no feature into the Update port.

 

The JSONUpdater always requires receiving a feature from the Update port, even if you don't need to use any attribute values from the Update feature.

If you have input no feature into the Update port, try adding a Creator and connect it to the port, like the screenshot attached. jsonupdater-with-creator

Thanks for the tip!

While that was also needed (it wouldn't work otherwise), the other piece that was needed was changing my Result Attribute from _result to ProgramProfile, as that is what I was trying to update.

I also found changing my JSON Text field from the incoming _result to the incoming ProgramProfile helped simplify the syntax.

 

Thanks again, this is now working how I intended!

Reply