423
Views
6
Comments
JSON Recordlist to key/value pair
Question
Application Type
Reactive

Hi, Everyone

I'm looking for a solution so I can convert my JSON data into Key/value pair list 

I have these data coming from SQL output as JSON and it is dynamic attributes can be more or less

[{"NAME":"Harrison","SURNAME":"Ford","ID":1},{"NAME":"Steven","SURNAME":"Spielberg","ID":2},{"NAME":"Ben","SURNAME":"Kingsley","ID":3},{"NAME":"Philip Seymour","SURNAME":"Hoffman","ID":4},{"NAME":"Alan","SURNAME":"Rickman","ID":5},{"NAME":"George","SURNAME":"Lucas","ID":6},{"NAME":"Sean","SURNAME":"Connery","ID":7},{"NAME":"Ben","SURNAME":"Stiller","ID":8},{"NAME":"Christopher","SURNAME":"Nolan","ID":9},{"NAME":"Robert","SURNAME":"Downey Jr.","ID":10},{"NAME":"Carrie","SURNAME":"Fisher","ID":11},{"NAME":"Priyadarshan","SURNAME":"singh","ID":12},{"NAME":"Lokesh","SURNAME":"Yadav","ID":13},{"NAME":"rithik","SURNAME":"Kumar","ID":14},{"NAME":"Manish","SURNAME":"Singh","ID":15}]


I just want to convert it into Key/Value pair list, if someone had solution or anyone can help.


Thanks in advance 

UserImage.jpg
Puja Rani

Hi,

Have you checked ardoJSON . This might help.


2025-07-31 10-32-21
Vikram garasiya

I tried it but nothing seems to work

2024-01-04 15-15-51
Abed Al Banna

Hi @Vikram garasiya 

You can use the JSON Deserialize for this.

1. Go to Data->Structures, then right click on Structures, choose Add Structure from JSON and paste your JSON there, it will automatically create the structure for you.



2. Drag and drop the JSON Deserialize node from the toolbar to the left, pass it the JSON String as input, and list of the structure you created from JSON as its data type. 

I hope this helps!

2025-07-31 10-32-21
Vikram garasiya

But I have dynamic json as I already mention that I can have more or less number of attribute from sql

2023-10-21 19-42-11
Tousif Khan
Champion

Hello

There is a Article on the requirnment where we have a dynamic Json and how we can handle it - https://medium.com/@jsmarques13/integrating-dynamic-structures-with-outsystems-6c45e36a4d47

Have a look on step by step guide

Thanks
Tousif khan

2025-07-31 10-32-21
Vikram garasiya

Hello, Everyone

I used JavaScript for this but when I take output as a text deserialization is not working properly. I'm sharing js with you. pls have a look.


let data=flattenJSON(JSON.parse($parameters.Text_Input));

$parameters.Out_text = JSON.stringify(data);

console.log(data);

function flattenJSON(jsonObj) {

    const result = [];   

 function flatten(obj, prefix = '') {   

   for (let key in obj) {    

    const value = obj[key];   

     if (typeof value === 'object' && value !== null) {   

       flatten(value, `${prefix}${key}.`);    

    } 

else { 

         result.push({ [key]: value });      

  }

  }  

  }  

  flatten(jsonObj);   

 return result;  }

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.