Question
Asurion
US
Last activity: 29 Jan 2016 13:24 EST
Modify JSON response Pega 7.1.7
Hi ,
I need to modify the one property name in JSON response.I found the below post from Mesh and PDN. But I don't see pzExternalName property qualifier in pega 7.1.7 as mentioned in it. is there any other way to do it ?
Re: How to modify the response JSON?
https://community.pega.com/support/support-articles/json-mapping-exception-after-migrating-pega-718
Thanks
Nagendran Arumugam
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems Inc.
CA
No Nagendran, you cannot use getJSON() and achieve this. getJSON() isn't aware of property qualifiers.
Pegasystems Inc.
CA
Can you tell me what's the JSON field name which you want to map to a Pega property?
Asurion
US
Hi Praneeth ,
We have a property named CustomerID , but the client is expecting field to be CustomerId in response. so when generating the JSON response I need the tag to be CustomerId not CustomerID.
Thanks
Nagendran Arumugam
Pegasystems Inc.
AU
It's been a little bit since I've used 7.1.7 and I can't recall if it uses the same mechanism, however are you able to add pzExternalName manually and test if that has the desired effect?
Asurion
US
I don't see pzExternalName in 7.1.7 , but this article(SA-14881) says it is a OOTB property qualifier . Not sure if it is added in 7.1.8. is there any other way to achieve this ?
Pegasystems Inc.
CA
Yes, the property qualifier pzExternalName was added in 7.1.8. But we recently ported this fix to 7.1.7. You could take this hotfix.
Pegasystems Inc.
CA
You need to take HFix-25262.
Asurion
US
Thanks Praneeth, I'll install the hot fix and see if it works.
Pegasystems Inc.
US
Please reply with the SR number that you created in order to obtain the Hot Fix so we can track it and connect your SR and this post in the Community.
Thanks!
Pegasystems Inc.
US
Thank you!
Asurion
US
Hi ,
I installed the hotfix and added pzExternalName in property qualifier but it did not work. Still the Json response is generating with propertyname and not with the value given in propertyqualifier value.
Asurion
US
please find the screen shot and response generated
"CustomerCase": [
{
"AgreementId": "1E571B850B6B03208D00005056A74B06",
"AssetId": "1E571B850AAA05308D00005056A74B06",
"ClientAccountId": "1E571B85091500D08D00005056A74B06",
"CustomerCaseId": "1E5AE757605107809AE9005056A74B06",
"CustomerCaseNumber": "1012119193",
"CustomerCaseStatus": "CMPLTD",
"CustomerId": "1E571B85091707E08D00005056A74B06",
"IncidentType": "DAMAGE",
"StartDate_str": "20151229T214521.797 GMT",
The response should contain StartDate instead of startdate_str
Pegasystems Inc.
CA
Are you parsing JSON and mapping to clipboard or generating JSON from clipboard?
Asurion
US
I'm generating JSON from clipboard
Thanks
Nagendran Arumugam
Pegasystems Inc.
CA
I just verified at my end and the outbound works as expected. After installing the hotfix, have you restarted your server?
Asurion
US
Hi Praneeth ,
We recycled the servers. This is what we are doing. we set the response property in data transform.
I set Property Startdate_str in data transform. I have mapped pzExternalName value to StartDate in Startdate_str property. we generate JSON response using function responseObjPage .getJSON( false );
I'm expecting JSON response to contain tag StartDate instead of StartDate_str. please let me know if i'm missing something.
Thanks
Nagendran Arumugam
Pegasystems Inc.
CA
If you are using property qualifiers, you are not supposed to generate JSON using the clipboard API getJSON(). You should instead have Map From as JSON on the response tab of your service REST rule and Map From Key should be the embedded page property whose JSON representation you need.
Asurion
US
Hi Praneeth ,
I'll check on this and let you know if it works.
Thanks
Asurion
US
HI Praneeth ,
is there any way to use getJSON() API and acheive this functionality? we use a common activity which gets the response page as parameter and generate the response for all the services so we will not be able to use Map from JSON.
Accepted Solution
Pegasystems Inc.
CA
No Nagendran, you cannot use getJSON() and achieve this. getJSON() isn't aware of property qualifiers.
Asurion
US
Thanks praneeth. I think we cannot use this function then. is it possible to tell me the class the MAP from JSON uses to generate the JSON ? may be i'll try to write some java code around the class and see if it works.
Pegasystems Inc.
CA
The method used by Map from JSON is tools.getServiceUtils().mapOutboundData(). You could see its usage in step 5 of Rule-Connect-REST.Invoke activity.
Asurion
US
Thanks Praneeth , I'll check if I can use it in our code.