Question
CBA
IN
Last activity: 18 May 2017 11:40 EDT
How to convert clipboard page to JSON format to send as a response to the service ?
Using getJSON method, I am getting pxObjClass as well converted to JSON format .I don't want that .Without pxObjClass getting added in the file ,Is there any other methods available to convert clipboard to JSON format. ?
Message was edited by: Marissa Rogers - Moved from Mesh Help, Added Category
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
IN
- @(Pega-RULES:Page).pxConvertPageToString(tools, myStepPage, "json") works?
-
Snehasis Panda
Pegasystems Inc.
CA
Even this RUF would add pxObjClass as it uses the same underlying API to convert clipboard page to JSON.
Mamatha, in what context do you need clipboard page to JSON conversion? Are you using REST service/connector?
CBA
IN
yes I am using REST Service -I want to pass few properties as input to Connect REST in JSON Format .
I have value in JSONresponse page .Using getJSON I convert that to JSON format .But it is having pxObjClass as well .Since the service will not understand the pxObjclass .I want to elimate that .
Pegasystems Inc.
CA
Have you tried using Map from as JSON and Map from key as your response page property on the Connect/Service REST rule? With this, the generated JSON wouldn't contain pxObjClass.
CBA
IN
Ok will try .Thanks Praneeth
Tata Consultancy Services
IN
Mamatha, could you please confirm if Praneeth's suggestion worked or not?
Capgemini
CA
how to get this sahu
Apple India Pvt Ltd
IN
Its not working.. could you let me know any other way
-
Charan Kumar Narra
Pegasystems Inc.
IN
>>> How to convert clipboard page to JSON format
create a java step in activity with the following code and share your observations, Thank you!
PublicAPI tools = (PegaAPI) ThreadContainer.get().getPublicAPI();
ClipboardPage stepPage = tools.getStepPage();
String returnValue = stepPage.getJSON(false);
RequestResponse = returnValue;
-
Manash Pratim Chaliha
Booz Allen Hamilton
US
Sahu,
Thank you for the code snippet. So if I have a Data-Class Customer with properties FirstName and LastName, and I have a Page for Customer on my clipboard, can I expect your code to spit out the following:
{ "FirstName" : "Tom", "LastName" : "Hanks" }
I would expect nothing less from the library function. The problem is if getJSON() is also streaming internal/base class properties into the JSON, which clearly is not intended. Ideally one should be able to define a Data-class, instantiate it, populate it, and then stream it out into JSON without side effects.
Really appreciate if you can confirm/clarify.