darshthakkar
3 years agoValued Contributor
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
Hi @manohar.
In the example you have listed, If i understand correctly don’t we also need to include the filename: Coupa_Supplier_SB_Tax_Cert_PO_4501888888? Because it exists in the docname array?
If yes, then you can use the following expressions:
$docname.filter((x,ind,arr) => $filename.indexOf(x) != -1) $docid.filter((x,ind) => $filename.indexOf($docname[ind]) != -1) $docext.filter((x,ind) => $filename.indexOf($docname[ind]) != -1)
Let me know if this helps.
BR,
Aleksandar.