Posted: 1 Mar 2017 14:31 EST Last activity: 16 Oct 2018 12:03 EDT
How do you get the RAW JSON from a clipboard conversion?
The client needs to do some specific logging and we are having to use the function pxConvertPageToString to get the JSON message. However Pega includes pxObjClass specifics in the produced JSON text as shown below. Is there a way to get the RAW JSON without the Pega information being included?
We are letting the rest connector perform the conversion itself from the clipboard when calling the actual service. However they have a hard requirement to log the raw JSON request and response. Response is simple enough as it comes back in the true raw format. However we have to use a conversion function to capture the request.
I checked the OOTB Pega Engine class Javadocs as well: found this call:
ClipboardPage.getJSON( boolean aEncode )
Unfortunately this also returns back the *full* set of properties in the page (including the 'pxObjClass' property and other 'px' props).
There might be another way: but I don't know it I'm afraid. (Aside from the 'subtractive' approach I gave above).
Maybe somebody else does ?
I have logged a 'Feedback' / 'Enhancement' Request here: (this isn't a guarantee of a fix of course; but it does allow our SMEs to review the viability of such a change). I have included the ID, title and text of the ENH below; and I have referenced this Post in the ENH itself.
FDBK-18584: ClipboardPage.getJSON : flag to eliminate px, py, pz props.
It seems that at least one customer is after a way of getting a JSON payload, based on a PRPC Clipboard, which *excludes* the 'pxObjClass' property.
I have therefore suggested a catch-all ENH here: a variation of the Method 'getJSON' that allows you to specify a regex to filter out matching properties.
So for instance you could specify something like: (And I mean 'something like' here: I haven't double-checked that Regex - it looks *about* right to me).
To drop / filter-out any 'px', 'py' or 'pz' properties.
Or you to JUST drop more specific properties; say 'pxObjClass':
Or maybe we shouldn't 'drop', instead we 'match' for *wanted* properties.
Or offer both types.
Then we could offer a 'convenience' pre-built REGEX that checks for system properties etc; and provide that as a 'constant' for the function.
Thanks, I have been through all the JSON methods I could find. It seems for all the exposed ones I can find they all add the pxObjClass stuff. What is weird is that when the REST connector runs there is a property on the clipboard that is raw (begins with a prefix of "Request Method =") except for a prefix. Shouldn't be this difficult to just get the raw JSON. Thanks for getting the ER in.
When you write your function it must accept the sourcePropertyRefAsStr parameter as a String. I was only successful getting a valid response when I pass the full page context. I named my function getJSON so it's called like: @getJSON("OFFER.getOffer")
To convert raw Json now in latest version it is simplified.Create data transform with Json format, once created use auto mapping which converts clipboard page to json and also have option to exclude Properties e.g. objclass whichever not required in the output json.output of the json is stored in out parameter of datatransform.