40
Views
6
Comments
JSON Object to Array Conversion
Question

I am receiving both Json object and json array from API, I need to convert those JSON object to Json array, Like Mentioned below

INPUT: -

{

   "jsonObject":

{

      "name":"John",

      "age":30,

      "city":"New York"

 }

}

OUTPUT: -

{

   "jsonObject":

[ {

         "name":"John",

         "age":30,

         "city":"New York"   
} ]

}

How to achieve this?

2024-12-02 13-16-47
Vipin Yadav

Hi shubhangi kendre,

You can create a structure according to your use because in OutSystems, an array is considered a list. 

I have attached the screenshot below for your reference. 

First Structure - 



Second Structure - 


Thanks,

Vipin Yadav

UserImage.jpg
shubhangi kendre

Hi Vipin


Example: I am getting a response from the API, it will have multilevel structure,

suppose if there is a object like 

{

"TCRMService" : {

 "Object1" : {

    "Name" : "CTS",

    "Place" : "Chennai"

"Object2" {

    "Address" : "P O Box 10",

    "Country" : "India"

}

}

}

system will pass this Json response to server action and expect output is below structure eventhough it is a single object.

{

"TCRMService" : {

 "Object1" : [{

    "Name" : "CTS",

    "Place" : "Chennai"

} ],

"Object2"[ {

    "Address" : "P O Box 10",

    "Country" : "India"

}]

}

}

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

This Forge component:

https://www.outsystems.com/forge/component-overview/413/ardojson-o11

Has many features to manipulate  and process JSON structures, maybe it helps.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Shubhangi,

Your question is exactly the same as that of Manikandan. Is it a colleague of you, or are you posting from two accounts?


2021-11-19 11-12-44
Rui Mendes

I had the same feeling here! 

2024-09-17 12-24-07
Rammurthy Naidu Boddu
Champion

Hi, 

Using java script to convert json to arrya object 

const ArrayObject = JSON.parse(<Json text>);

 

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