Skip to main content

Hi!

I have a problem with JSONUpdater and the function "Delete From Array".

 

My case :

I have this JSON file

im1I want to delete the value 79240 in "structure_ids". In JSONUpdate, I can't write the value, it doesn't work.

im4I do write the position of this value.

How can I do this dynamically? Is there an IndexOf function on FME?

And when I write a position, here 4, in JSONUpdater, it removes 2 values ​​instead of one (79240,79389).

res1 

Thank you for your help

 

Using the index of position 4 should work here and it does correctly for me with your example.

Do you definitely only have one feature going to the update port?


hi edygomm! you're right, i have two feature going to the JSONUpdater. Now I have only one and it removes 1 value in my array.

Do you have an ideas how I can get the position of a value in an JSON array?


hi edygomm! you're right, i have two feature going to the JSONUpdater. Now I have only one and it removes 1 value in my array.

Do you have an ideas how I can get the position of a value in an JSON array?

I don't know an FME way, I would probably end up resorting to python to remove the value from the array


Hi @lribot​ 

If you're familiar with XQuery, you can use the index-of function, as our XQuery transformers such as the XMLXQueryExtractor supports JSONIq extension.

If you prefer not to use XQuery, it should be possible using a JSONFlattener and ListSearcher. However, this method would not be suitable if there are multiple instances of 79240 as the ListSearcher only matches the first instance.


Hi @lribot​ 

If you're familiar with XQuery, you can use the index-of function, as our XQuery transformers such as the XMLXQueryExtractor supports JSONIq extension.

If you prefer not to use XQuery, it should be possible using a JSONFlattener and ListSearcher. However, this method would not be suitable if there are multiple instances of 79240 as the ListSearcher only matches the first instance.

Thank you so much debbiatsafe! It works.


Reply