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
  • 137 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

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.

4 replies

david_r
Celebrity
  • 8391 replies
  • 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
  • 13 replies
  • 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
  • 8391 replies
  • 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

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
  • 13 replies
  • October 17, 2022

ok thank you for this explanation