30
Views
2
Comments
Building dynamic JSON from database config
Question

Hello,


I am wondering if anyone had experience with building JSON files dynamically based on some predefined configurations (stored in a database table for example).

To give some context, we have to POST data from OutSystems towards an external party via REST APIs and the attributes/amount of data we send can increase as time passes, that's why working with a static structure is not that feasible (since we'll have to go through the deployment pipeline everytime we change something).

For that reason, we thought of keeping a configuration in a DB table, like which are the source & target attributes as well as the JSON path and based on that we could build the JSON dynamically. I know ardoJSON component offers some utilities to Objectify a JSON text, but not sure if it's the way to go forward.


Thanks,

Bogdan

Hi Bogdan,

In my (limited) experience with building dynamic JSON structures, what I have done is basically store or represent the fields in a Key/Value type of structure that can later be converted into JSON by using actions such as the ardoJSON component (Listify/Objectify). 

Just a disclaimer from my experience, some of the actions in the component didn't necessarily work quite the way I expected for some use cases (mostly with multilevel/nested structures), so depending on your situation, you might have to build some utility functions and/or represent the structure in a more complex way to fit your needs, but the general concept should still work.

Hey Francisco,


Indeed, I have already used the JSON_Objectify action for simpler use cases, where the structure was less complex, but in my case I will be working with quite some levels of nesting and more complex structures.

I'll see what I can achieve :) Maybe there are other C# libraries that could help me with this, I will investigate more.


Thanks,

Bogdan

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