Hello, Consuming a REST API which returns JSON object with dynamic key and value. Example of the response:
{
key1 : "value1",
key2 : "value2",
key3 : "value3",
key4 : "value4",
}
So, is it possible to parse data without use of any forge component?
Hi @Rashpal Singh
If you not willing to use any forge component then use this way
Get response from API as Text/Plain instead of JSON structure
Currently the JSON will be stored inside the text variable.
Then use built in replace function to remove all { and } in JSON
Then use string split by using comma(,) as delimeter,
it will give list of values like
[0] => key1 = value1
[1] => key2 = value2
Create one structure like this
Structure name - JSON Data
Attribute 1 = key
Attribute 2 = value
Create one local variable as JSON Data list as data type
Then use for each loop which takes string split's output list as input
Then again use string split function inside for loop to split using Colon(:) delimeter for each record
Then use list append to add those data in the local variable we have created. key =Stringsplit.list[0].text.value and value= Stringsplit.list[1].text.value .
But I suggest to use some other forge component for optimised solution
Regards
Murali