Question

How to edit exposed attributes of a jsonfragmenter dynamically?

  • 23 February 2022
  • 6 replies
  • 16 views

Badge

Hi, my attributes to expose in an jsonfragmenter comes from an user defined parameter, but I have to insert array brackets (like "WIND_6H{}"). How can I do this? It is only possible to edit this list manually or to take userdefined parameters, but not to edit the parameters dynamically.

Thank you for your help!

Christoph


6 replies

Badge +20

I don't really understand what you need to do.

Do you need to dynamically expose attributes? SchemaScanner should help with this.

Please give us some more detail. Where is the JSON coming from? A file, an attribute, HTTPCaller?

Badge

Hi, the json comes from a httpcaller and the attributes to expose should come from the user parameters.

 

imageimagethe source of exposable attributes can only be manually created list or from the user parameters.

No way to dynamically insert a "{} " for an array attribute ...

 

Possibly there is another transformer to do this?

Userlevel 4
Badge +25

I think what you need to do in that case is a simple Choice parameter, where you show a list of the attributes to the user, but the actual value you return has the {} part applied.

 

Alternatively, you could use nested parameters. For example, create a choice or text parameter and then use the contents of that parameter inside a Scripted (Python) parameter to build the correct value.

 

It should be fairly straightforward, but let us know if you experience problems.

Userlevel 4
Badge +25

I tried doing this as part of my question-of-the-week video last week, and made a complete mess of it! So I went back and looked into the issue and how to properly solve it. I hope you find this useful:

 

https://youtu.be/Fvhqwrzd6IM

 

I think the key issue is why do you need to expose attributes? To get them in the output? In that case just using a dynamic writer is the best way and - as mentioned above - the SchemaScanner is a great way to manage that.

 

Userlevel 4
Badge +25

I don't really understand what you need to do.

Do you need to dynamically expose attributes? SchemaScanner should help with this.

Please give us some more detail. Where is the JSON coming from? A file, an attribute, HTTPCaller?

You know, I had a try at this and eventually realized that you were right all along and that a SchemaScanner is the best solution. If you want to check out how I used it, here's a link to the new video: https://youtu.be/Fvhqwrzd6IM

Badge +20

You know, I had a try at this and eventually realized that you were right all along and that a SchemaScanner is the best solution. If you want to check out how I used it, here's a link to the new video: https://youtu.be/Fvhqwrzd6IM

@mark2atsafe​ FME Community 1 - 1 Safers 😁

I checked out the solution, your thought process is good. Very nice of you to include some limitations.

I never got around on doing a follow-up.

You should upload your workspace for future reference on this solution.

Reply