642
Views
11
Comments
Solved
How to serialize text data in a JSON format.?
Application Type
Reactive

I want to show my entire row data in a container in JSON format, 

But when I am getting data in that container it is not in the JSON format.

I want to display this data in JSON format.

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

Hi Keshav,

What you're showing in that image seems to be the header of your HTTP request. Where did you get that data from?

Also note that it isn't possible to get the exact JSON of the particular row. The entire payload of the REST method is deserialized, and it contains the data for all rows, each row as an element of an array. So there's no actual JSON per row available anymore. The best you can do is reconstruct it, based on the data in the columns, but that would defeat the purpose I think.

UserImage.jpg
Keshav Raghav

The data is nothing but the audit logs, of our team.

I used a action column, which on click shows the entire row data in JSON format. 

So is it not possible you are saying?

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

Well, for starters, looking a bit better, this is actually correct JSON. There is a RequestId and a RequestBody, which are attributes in the JSON object. What you, probably, want to have is just the RequestBody part, but the RequestBody also contains the HTTP and other headers (like Accept-Encoding and Authorization and so on).

So what do you want to show? The RequestBody attribute as JSON? If so, you need to deserialize the JSON object you have currently, then un-escape the content RequestBody attribute. Then you might need to format it to be legible, as currently it's just one big line.

Is it possible? Probably, but it isn't easy.

UserImage.jpg
Keshav Raghav

The action column has one parameter called line, which contains the whole data of the row in JSON format. Now I just want to format it correctly, like I want to add spacing and new lines on each attribute. 

I need to display the data in a more user friendly way. 


I have data in JSON format, I just need to display it in more understandable way.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
UserImage.jpg
Keshav Raghav

I cant use forge components. As it is restricted in my company.

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

That's an incredibly stupid restriction. The Forge's purpose is to provide developers with ready-made components that extend the Platform.

That said, you could always download the component en look at the code, copy/pasting what you need.

2023-03-16 16-29-51
Paulo Rosário

Hello Keshav,

You can use the SerializeJSON action from OutSystems. Keep in mind that you will need to create a structure that matches your original JSON file. 

To do this you can use the option to add a structure from JSON in Service Studio by right-clicking on the Structure folder of the Dat tab.

This will add a structure that matches your text, and that you can then use to Serialize it.

Hope it helps!

Paulo Rosário

UserImage.jpg
Keshav Raghav

Then how I am able to show it in a pop-up.? I have added a expression in pop-up, which requires text data type.

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

Hi Keshav,

What you're showing in that image seems to be the header of your HTTP request. Where did you get that data from?

Also note that it isn't possible to get the exact JSON of the particular row. The entire payload of the REST method is deserialized, and it contains the data for all rows, each row as an element of an array. So there's no actual JSON per row available anymore. The best you can do is reconstruct it, based on the data in the columns, but that would defeat the purpose I think.

UserImage.jpg
Keshav Raghav

The data is nothing but the audit logs, of our team.

I used a action column, which on click shows the entire row data in JSON format. 

So is it not possible you are saying?

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

Well, for starters, looking a bit better, this is actually correct JSON. There is a RequestId and a RequestBody, which are attributes in the JSON object. What you, probably, want to have is just the RequestBody part, but the RequestBody also contains the HTTP and other headers (like Accept-Encoding and Authorization and so on).

So what do you want to show? The RequestBody attribute as JSON? If so, you need to deserialize the JSON object you have currently, then un-escape the content RequestBody attribute. Then you might need to format it to be legible, as currently it's just one big line.

Is it possible? Probably, but it isn't easy.

UserImage.jpg
Keshav Raghav

The action column has one parameter called line, which contains the whole data of the row in JSON format. Now I just want to format it correctly, like I want to add spacing and new lines on each attribute. 

I need to display the data in a more user friendly way. 


I have data in JSON format, I just need to display it in more understandable way.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
UserImage.jpg
Keshav Raghav

I cant use forge components. As it is restricted in my company.

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

That's an incredibly stupid restriction. The Forge's purpose is to provide developers with ready-made components that extend the Platform.

That said, you could always download the component en look at the code, copy/pasting what you need.

UserImage.jpg
Miguel Reis

@Keshav Raghav Replace all your quotes with double quotes and enclose the whole thing in "".
example:


{"RequestId": 

would turn into

{""RequestId"":


you can use notepad to replace all

UserImage.jpg
Keshav Raghav

Can you please share oml for reference purpose.?

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