Wednesday, December 11, 2019

How to SERIALIZE OR DESERIALIZE using Data Transform

While creating Data transform, there are two options of "Data Model format" i.e. Clipboard or JSON. This post talks about data transform of format JSON with a basic example:


In this scenario, by default you would notice the below parameters in Data transform:




DESERIALIZE:



In this example, given a JSON data we can map it to clipboard page using Deserialize option.

Data Transform is created in the "Data-Employee" class in this example, and will be invoked from the same context in step #3 below



Input => jsonData // with Employee details in format shown in step #2 of above screenshot
Output=> EmployeePage// Page populated from jsonData i.e. in this example EmployeeID and EmployeeName to be populated.

On executing this activity at step #3 you can notice that json is mapped to clipboard structure as expected.





SERIALIZE:

In this example, given a clipboard page; when Param.executionMode is passed as "SERIALIZE" it gives an output of JSON. This scenario falls into serialize category:
Reference: Step #5 from above screenshot of activity.

Input => Param.executionMode="SERIALIZE", Param.jsonData="" // with Employee details populated
Output=> jsonData// jsonData
Data Transform is created in the "Data-Employee" class in this example, and will be invoked from the same context.

On executing this activity at step #5 you can notice that clipbard page data is mapped to jsonData parameter.


Here we have seen both the cases DESERIALIZE and SERIALIZE.

Post Credits: Ranganath

Food for thought:

What if we do not need pxObjClass in the JSON generated from Pega. What could be the ways of achieving it? (Reason being outside Pega pxObjClass doesnt hold any significance, so lets say there is a requirement for us to remove pxObjClass from jsonData).

3 comments:

  1. Hi Pavan,

    I have tried the same but in Deserialize it is working as expected. when i tried for serialization Param.jsonData has only pxobjclass value alone not remaining structure sets in property set. please advise. if required i can share screen shot also.

    ReplyDelete
  2. Hi Karthick, Can you re-look at the steps in serialize scenario. Can you mention the class name and properties you are trying to serialize. I can help you there.

    You can place your screenshot in Facebook i.r. HowToPega page. I can reply there too.

    ReplyDelete
  3. Hi Pavan,
    I am facing issue with SERIALIZE execution mode when I am trying to create request JSON data transform for POST method. What should be passed in Param.jsonData??

    ReplyDelete


HowToPega : All rights reserved and the contents are copyrighted to Pavan Kumar Naidu