IT Process Automation

best practice recommendation to deserialize, modify and serialize Json values ?

  • 1.  best practice recommendation to deserialize, modify and serialize Json values ?

    Broadcom Employee
    Posted Apr 18, 2017 06:22 AM

    One of our customers is using PAM's HTTP Operators to communicate with CA Service Desk RESTful webservices.

    They retrieve a Change object using HTTP Get and use the following post-execution code to deserialize
    the Json String into a ValueMap:

     

    Process.Chg = newValueMap ();

    Process.Chg =convertJson(Process[OpName].HTTPResponseContent);

     

    After that they modify the Object:

    Process.Chg.chg.description = "Description Changed";

     

    Next they want to execute a HTTP PUT to update the Change object in the USD.

    Is there a way to get the Json representation of the object Process.Chg back from the ValueMap? 

     

    There is another way to create a JS Object from Json string using the parseJson function:

    https://docops.ca.com/ca-process-automation/4-3-1/en/reference/operators-reference/system-functions/parsejson-function

    And the way back to Json should be stringifyJSON

    https://docops.ca.com/ca-process-automation/4-3-1/en/reference/operators-reference/system-functions/stringifyjson-function

     

    Is there a best practice recommendation to deserialize, modify and serialize Json values ?