Hello All,
I have a requirement to convert a CDT value into specific Json Format, Here is the scenario
Suppose there is variable called "initialCDT", Such as
local!initalCDT:{
{
type!abc(
Key:"NoOfPages",
Value:{1,2,3}
},
type!abc{
Key:"WordCount",
Value:{5,6,7}
}
Now I have some other variables as well holding some values but the the above variable can have dynamic number of Key Value pairs. So My requirement is to create a Json String like below
"Title":"Journey to West",
"StartDate":"2018-10-08",
"EndDate":2018-12-08",
"ProcessParameters":{
"NoOfPages":{1,2,3},
"WordCount":{5,6,7}
Here the ProcessParameter is made from the variable declared above and the format should be exactly the same, Otherwise the API method will fail, Can someone please assist me here? Thanks in advance
Discussion posts and replies are publicly visible
You can use a!toJson to convert any KVP into a JSON string like the one your requirement specifies. If you have a CDT that holds the title, startdate, enddate, and process parameters, you could even do a toJson on the CDT itself. Otherwise, you can manually create a dictionary that holds all that data and then wrap it in a toJson. Sort of like this:
a!toJson( { Title: ri!title, StartDate: ri!startDate, EndDate: ri!endDate, ProcessParameters: { NoOfPages: ri!numPages, WordCount: ri!wordCount } } )