Eliminate pxObjClass in JSON String using Regex

When converting a pagelist/page to JSON string, it will also consider the "pxObjClass" property in pega. 

Now we are going to see how to remove pxObjClass property in JSON String using Regex. 

Example: 

The Clipboard page displayed below will be converted to the JSON String and pxObjClass property in the JSON string will be eliminated by using below mentioned function and the REGEX.

Using Property-Set method to invoke the function pxConvertPageToString by using this function we are going to convert the Clipboard page into the JSON string using below function 

@(Pega-RULES:Page).pxConvertPageToString(tools, sourcePage, "format") 

To know more about the above function check out the below link : https://simplypega.blogspot.com/2021/05/convert-clipboard-page-to-json-string.html

The Original JSON string after conversion (with pxObjClass) will look like as below

Once the page is converted into a string, you can remove the pxObjClass from the JSON string using below REGEX.

@pxReplaceAllViaRegex(JSONString,",.*?\"pxObjClass.*?\n","") @pxReplaceAllViaRegex(JSONString,".*?\"pxObjClass.*?\n,","")

After the successful execution the pxObjClass will be eliminated from the JSON string as shown below

Happy Learning 😁!!!


Popular Posts