Question

Pega encloses decimal property values in Double Quotes in JSON response object
Hello,
We are generating JSON response object using getJSON() method. This method is enclosing double quotes around all the property types (Decimal, Date, Boolean, Integer) and making it as string. The consuming system is taking it as String instead of it's original property type.
Ex: I have a property ;Amount' of type Decimal. This property has to be incorporated into JSON as Decimal, but getJSON() method forming JSON object with Amount as String.
JSON Output:
{"ServiceFee": {
"Amount": "200.25",
"CurrencyCode": "USD"
}}
Is there any way to get rid of the double quotes in JSON and rather than converting it to String, can we form the JSON object with it's original property types.
Thanks !!!
Kartheek Kalluri.
Message was edited by: Vidyaranjan Av | Included category
-
Like (0)
-
Accepted Solution

Have you tried using Map from as JSON on the response tab of the Service REST rule? When you do this, the property type is taken into account while generating JSON.

Are you using this JSON in the context of a Connect REST or Service REST rule?

Referenced SR-A23486. Giri Ganji, can you please answer Praneeth's question?

Provided this update to Giri on SR :
Hello Kartheek, Giri,
I have taken ownership of this ticket for research and resolution. From my understanding of the getJSON method, its purpose was only intended to create a simple JSON "clipboard" representation of the step page and therefore does not resolve the "Pega type" to a valid "JSON type". Everything is represented in JSON as strings. As you probably have noticed, it also adds pxObjClass for context.
I see you have posted to Product Support forum. We can certainly use that in our investigation. https://mesh.pega.com/thread/59235
Can you provide the answer to the question posed there?
"Are you using this JSON in the context of a Connect REST or Service REST rule?"
One proposal that may have merit is to consider a parse rule to transform a clipboard page into the JSON output to meet requirements.

Hello Praneeth,
We're using JSON in the context of "Service REST".
Yes, getJSON method creating the Clipboard page into JSON as Strings. This may be as intended. However, we wanted to retain Page data types into valid JSON data types. I wish to explore other options (if any).
Thanks,
Giri
Accepted Solution

Have you tried using Map from as JSON on the response tab of the Service REST rule? When you do this, the property type is taken into account while generating JSON.

Hi Praneeth,
Thanks for the reply.. Yes, It's working when we change Map from as JSON.. I guess, we're good with this.
Thanks,
Giri

Praneeth Purighalla when we use MAP from JSON , the generated response contain empty value pair as below. even though the property is not there in the page
{
Detail
{
"EndDate": "",
"StartDate": "2015-12-03",
}
}
The EndDate property is not in the Detail page , but it is a property in that page class. is there any solution for this ?

not sure would this resolve by setting the DSS 'DetectEmptyProperties' to true OR have a when condition evaluating the property value not to be blank before setting the value.
- Owning Ruleset : Pega-IntegrationEngine
- Purpose : StreamXML/DetectEmptyProperties
- Value : true

Hi Phani ,
The property is not set the page , but while generating JSON pega is adding null values for the properties in the class if it is not present in the page.

This can only occur if EndDate is present on the page, maybe it is just initialized to empty string via data transform. To get rid of it in the JSON, you need to remove it from the page using Property-Remove.

That's true.. It is picking the properties from Clipboard.. Let the team look at the code in question and confirm.

Hi Praneeth,
I am passing request using pyRequestAttachmentPage in key value pair where one of value needs to be passed in json.
When i am generating json i am geetting pxobjclass also..is there anyway to get rid of pxobjclass?
Thanks.