Forum Discussion

darshthakkar's avatar
darshthakkar
Valued Contributor
3 years ago
Solved

Sort field names alphabetically in JSON source data

Hi Team,

I have my source data coming in JSON format. I want to sort the fields inside the JSON format alphabetically. One way is to use a mapper and arrange them one-one alphabetically but it is a tedious task if the fields are more. Can we use an expression in mapper or any other snap that does this for us?

Thank you.

Best Regards,
Darsh

  • @shashish.jha - welcome to Community!

    It looks like you want to generate dynamic HTML using the JSON document input wihtin a pipeline, correct? One out-of-the-box solution is to use an XML Generator snap. This does make the syntax a little more strict since XML requires open and close tags, but it will work. I’ve attached an example.
    Dynamic HTML_2023_02_27.slp (7.7 KB)

    To try it out, just upload the pipeline, create a triggered task, and call it from a browser.

    If you want something a bit easier to use that supports CSS and HTML Script within the HTML body, you can contact your CSM to request the HTML Generator custom snap.

    Hope this helps!

12 Replies