Question
Softtech Yazilim Teknolojileri Arastirma Gelistirme Ve Pazarlama Ticaret An
TR
Last activity: 5 Mar 2021 15:40 EST
Creating Data Transform from Json File/Text
Is there any solution about creating data transform from json object/file.
For example:
{
".Name": "John",
".LastName": "Doe",
".BirthDate": "2017-05-24 14:25:05"
}
will create data transform with set operations like that.
Thanks.
-
Likes (1)
Dovydas Baseckas -
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems Inc.
GB
In 7.3.1+ you can create a Data Transform with "Data model format" (under "Additional configuration options") to 'JSON'.
The simplest case; you can just set 'Auto-map all date' - keeping the "top element structure" as "Object".
That's it; the incoming JSON (so long as it 'fits') - will get mapped to the named properties.
(In fact, the properties don't actually have to exist to demonstrate the Data Transform working - but you'll want to create them in real life).
You then call the DT with two PARAMs:
jsonData
executionMode
Set 'executionMode' to "DESERIALIZE"; set the jsonData to the full string of the JSON.
[ NOTE: I had to change your JSON - the leading "." (dot) doesn't work - since (I presume) that is ambiguous for the PRPC expression language - where the "." prefix is used when deferencing Properties; basically you are not allowed property names that start with a "." (dot) ]
So your modified JSON looks like this:
{"Name": "John","LastName": "Doe","BirthDate": "2017-05-24 14:25:05"}
And the result page looks like this:
In 7.3.1+ you can create a Data Transform with "Data model format" (under "Additional configuration options") to 'JSON'.
The simplest case; you can just set 'Auto-map all date' - keeping the "top element structure" as "Object".
That's it; the incoming JSON (so long as it 'fits') - will get mapped to the named properties.
(In fact, the properties don't actually have to exist to demonstrate the Data Transform working - but you'll want to create them in real life).
You then call the DT with two PARAMs:
jsonData
executionMode
Set 'executionMode' to "DESERIALIZE"; set the jsonData to the full string of the JSON.
[ NOTE: I had to change your JSON - the leading "." (dot) doesn't work - since (I presume) that is ambiguous for the PRPC expression language - where the "." prefix is used when deferencing Properties; basically you are not allowed property names that start with a "." (dot) ]
So your modified JSON looks like this:
{"Name": "John","LastName": "Doe","BirthDate": "2017-05-24 14:25:05"}
And the result page looks like this:
<?xml version="1.0"?>
<pagedata>
<pxObjClass/>
<LastName>Doe</LastName>
<Name>John</Name>
<BirthDate>2017-05-24 14:25:05</BirthDate>
<pzStatus>valid</pzStatus>
</pagedata>
Here's my DT (check the PARAMs tab as well):
Here's my test Activity showing how to call the DT:
-
Matthew Walters Sukumar Sarika
Barclays
IN
Once JOSN data is transformed to Page, embedded pages are classless and actual properties are not present is data model
is there any way to map this classless data on other case properties ? without creating exact response data model
Updated: 5 Jun 2020 7:05 EDT
Swedbank
LT
@JOHNPW_GCS Do you have any information or update on the issue described by @GANESHA19 that auto-mapped data becomes classless? How to re-map classless Pagelists to regular ones afterwards?
@GANESHA19 maybe you have figured out a workaround to this issue?
BPM Company
NL
One problem here.
If my JSON property name does not match Pega name, normally we use pzInternalName qualifier.
But it seems that JSON data transform does not pick up this definition.
Is there a workaround for that? (assuming I still want to use Auto-map all data checkbox)
Bimbo Bakeries USA
US
@vaspoz Hey Vaspoz,
Did you find any resolution for this. Even I am facing same issue. I do have pzExternalName qualifier in my Pega Property but the JSON data transform not picking up. If you find any resolution pls post it over here.
-
Romain Piederriere
Softtech Yazilim Teknolojileri Arastirma Gelistirme Ve Pazarlama Ticaret An
TR
Thanks for the answer John, that works.