Forum Discussion

negi_sagar's avatar
negi_sagar
New Contributor II
3 years ago
Solved

Help with adding a field in JSON output

I have a JSON output like this: { "Choices": { "1": { "Display":"Generating standard, automated reports (e.g. ERP, reporting tools)?" } "2": { "Display":"Generating non-standard / custom reports (...
  • Aleksandar_A's avatar
    3 years ago

    Hello @negi_sagar,

    You can try by using a Mapper Snap with Pass-through enabled:

    For Choices try using the below expression:

    $Choices.extend({[Math.max(...$Choices.keys().map(x => parseInt(x))).toString()]:$Choices.get(Math.max(...$Choices.keys().map(x => parseInt(x))).toString()).extend({"TextEntry":"true"})})
    

    Sample pipeline:
    SL-comm-add-field-to-max-in-json_2023_03_20.slp (4.4 KB)

    Let me know if this helps you.

    BR,
    Aleksandar.

  • negi_sagar's avatar
    3 years ago

    Thank you Aleksandar for answering this quickly and it worked.

    Can you tell me some resources from where I learn to create these expressions?