Skip to main content
Question

How to edit exposed attributes of a jsonfragmenter dynamically?

  • February 23, 2022
  • 6 replies
  • 120 views

cheffing
Forum|alt.badge.img

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

caracadrian
Contributor
Forum|alt.badge.img+23
  • Contributor
  • February 23, 2022

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?


cheffing
Forum|alt.badge.img
  • Author
  • February 23, 2022

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?


mark2atsafe
Safer
Forum|alt.badge.img+46
  • Safer
  • February 24, 2022

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.


mark2atsafe
Safer
Forum|alt.badge.img+46

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.

 


mark2atsafe
Safer
Forum|alt.badge.img+46
caracadrian wrote:

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


caracadrian
Contributor
Forum|alt.badge.img+23
  • Contributor
  • March 2, 2022
mark2atsafe wrote:

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings