Skip to main content
Solved

Hi! I have a question about JSONUpdater. I want to insert a new value in a array. I read some articles about JSONUpdater on FME Community but I don't find a solution to my problem.

  • October 17, 2022
  • 4 replies
  • 109 views

image.pngThis is my JSON file.

I want to insert, in "structure_ids" array, the value 79538.

imageimageMaybe the problem is my value, I can't write it like that.

 

Thanks for your help

 

Best answer by david_r

I believe the issue is that the JSON Path does not contain the target array name. Also, the Array Index should not contain the array name, but an integer index. Alternatively, you can set the update type to Append to avoid having to specify the index. For example:

 

image

View original
Did this help you find an answer to your question?

4 replies

david_r
Celebrity
  • Best Answer
  • October 17, 2022

I believe the issue is that the JSON Path does not contain the target array name. Also, the Array Index should not contain the array name, but an integer index. Alternatively, you can set the update type to Append to avoid having to specify the index. For example:

 

image


  • Author
  • October 17, 2022

Thank you so much, it works!

I just have an additional question. Do you know why, when I look at json text resulting from this transformation, the inserted value has double quotes.

image


david_r
Celebrity
  • October 17, 2022
lribot wrote:

Thank you so much, it works!

I just have an additional question. Do you know why, when I look at json text resulting from this transformation, the inserted value has double quotes.

image

Unless FME is completely certain, it has a tendency to default to string data types, which is why you get the double quotes.

You can cast (force) the values to int by using the following expression in the JSONUpdater:

image


  • Author
  • October 17, 2022

ok thank you for this explanation

 


Reply


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