GetRecord - JSONSerialization - JSONListify - JSONDeserialize - ?? - UpdateRecord

I have a question about manipulating JSON.

For peculiar reasons (some very large entities with over 50 attributes), I want to be able to serialize an Outsystems record into JSON, turn it into a series of {key : value} pairs, turn it into a record list of data type key, value Record List do some work in it and then convert it back into the original Outsystems record and update it.

I have reached as far as saving the data to a record list of data type key, value Record List.  But the final steps to convert it back to the original record are eluding me.  Here is a screen action mimicking the process:

I can Deserialize the JSONSelect output back into the original record, but I cannot readily convert the JSONListify.JSONOut or the JSONDeserializeListify.Data back into the original record.  Is there a standard pattern to achieve this.

Using a simple (and small) record structure the results look like this:


Hello Charles,

Can I ask you why do you need to Serialize, Listfy, and then put back into a record?
What are you trying to do with the text that you can't do with the record directly?

Cheers.

Hi Eduardo 

We have a number of large entities that undergo complex processing, as the business changes we want to be able to add entities or even add attributes to entities without changing the complex processing.  These processes blindly step through each attribute and perform a series of actions on each attribute.  In the past, we have built processes based on the specific attributes in each entity, however as our entities are about to change from 40 attributes to over 100 and likely to change again, it seems a good time to have a different approach. 

Normally, I would agree that we should keep the data in an entity / outsystems record and use Outsystems with the benefits to TrueChange etc to manage and maintain the processes.  However, the nature of what we are doing is very repetitive and cumbersome to build on a flat record (an assign with over 40 attributes takes a long time to load in DE).  We could normalise the data into a table of key : value records, but this would incur overheads when we come to query the data after processing it.  An alternative approach is to process the data in a key : value table and then re-structure it in a post processing table ready for efficient query handling. However, I thought doing this on-the-fly with JSON would be a more elegant solution. 

In addition, learning how to do this would fill a gap in my understanding of how to handle JSON structures in Outsystems.

cheers

Solution

Hello Charles,

I understand. 

What you need is JSON_Objectify action. It will receive a list with a pair of name:value in the format of the Listify and put back as a normal object. Then you can use the Deserialize to create again the structure using its output. My version of ardoJSON has as the output of Listify a key:value, but as the Objectify expects a name:value, I just change it first:


Then I do the Objectify and use its output as the source to the Deserialize:

Here it worked and I successfully was able to reconstruct the record.

Cheers.


Solution

HI Eduardo

Thanks, that is very helpful.  I think the name : value / key : value was the problem.  A pity that issue it is not better documented.

Charles


Hi Eduardo

I had to modify your solution slightly, and place a JSONSerialize action after the processing and then apply the Replace (key, name) action to the result...


Hi, 

This makes sense, as I bypassed one of the steps just to show the Objetify :)

Cheers