Skip to main content

Hello,

Lets say I have given JSON structure being passed to FME workspace as a published parameter value:

{


"users": [

{"user":"John", "age":"33"} ],

"otherParameters" : [ {"name":"parameter1", "value":"NULL"}, {"name":"parameter2", "value":"NULL"}]

}

It may contain different users and otherParameters

I would like to add a transformer/tester at the begining of the workspace flow so that if in the json there is a user with the name John and age 33 then do some things and if tha age is different or for example users list is empty do others.

What would be the best approach to do that? Thanks in advance.

I I know how to do it using python private parameter. Parse JSON in script and store true/false value in private parameter but maybe there is different way using different transformers.


You can use the json flattener to parse the parameter value and use a tester on the parsed values.


@itay is right, the JSONFlattener might be the easiest solution. Here's the result (as shown in the Inspector) from your sample json block:

You can then use a ListExploder and/or a ListIndexer to access the individual list items.


Agree. Then, in order to determine if the "users" array contains a {"user": "John", "age": "33"}, you can use a combination of ListSearcher and Tester after flattening. e.g.


Reply