Extract information from a text property that contains a JSON

Hello everyone,

I would like to know how can I extract the information form a Text property that contains a JSON text? The property contains this JSON:

{“title” : “Test title”, “Url” : “http://www.test.com”, “Category” : “Testing”}

I have to map those 3 values to 3 different properties.

Thank you,

Josué Dávila

Hi ,

You can use below function and pass the your json string and page where you want to extract the data

@(Pega-RULES:Page).pxConvertStringToPage(tools,myStepage,Param.Inputparam,“json”)

Thanks,

Deva

I solved this doubt using an Activity, first creating a Page-New step with the class that contains the same properties as the JSON. In this case the class I used for the new page had the properties of “Title”, “URL” and “Category”.

Then, in a Property-Set step I used the boolean function @importJsonOntoPage(String json,ClipboardPage cbPage).

I mapped the function to a boolean Parameter and the three values from the JSON were mapped to the correct properties of the Page and the class.

Image attached:

OfferWorkPage.Treatments(1).AdditionalDataJSON = {“Title” : “Test title”, “Url” : “http://www.test.com”, “Category” : “Testing”}

PushHistory = Page-New of a class