JSONP Response Mapping
Hi,
I have a requirement where I need to map the response coming form an external system.
The external system is sending the response in JSONP (JSON with padding) format.
Tried with JSON mapping but it doesnt work.
Tried pxConvertStringToPage function but it throws the below error :
** Java Exception: java.lang.ClassCastException: com.pega.pegarules.data.internal.clipboard.ClipboardPropertyImpl cannot be cast to com.pega.pegarules.pub.clipboard.ClipboardPage
Please suggest some steps.
Regards,
Nisarg Kothari
Nisarg,
You will need to do some string manipulation to clean up the response before passing it to the json mapping.
A normal json response would be:{"Name": "Foo", "Id": 1234, "Rank": 7}
The jsonp response would be: mycallback({"Name": "Foo", "Id": 1234, "Rank": 7});
So you need to strip off "mycallback(" from the beginning and ");" from the end before passing the text to the json mapping. To do this you could use a Parse Normalize rule or a data transform that that just trims the first first 11 chars (or whatever number depending on name of callback) and last 2 chars (or any expression technique that strips out the chars.
Let me know if this helps
Cecil Howell
CSA | Senior Instructor | Pegasystems Inc.