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.

  • 17 October 2022
  • 4 replies
  • 12 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

 

icon

Best answer by david_r 17 October 2022, 12:40

View original

4 replies

Userlevel 4

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

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

Userlevel 4

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

ok thank you for this explanation

 

Reply