View the Documentation Site for complete API details.
You must be on PeopleTools 8.55
or later.
Download and import the PeopleSoft project into App Designer
The PS-Jsonify library offers three consumer App Classes: PSM_JSON:Object
, PSM_JSON:Array
, and PSM_JSON:Node
. These three classes can be used to build and parse JSON Objects, Arrays, and Nodes respectively.
Use the PSM_JSON:Object
Class to build JSON Objects.
Local PSM_JSON:Object &oJson = create PSM_JSON:Object();
The various AddXxx
methods allow you to add PeopleCode object types to the JSON Object.
Local Rowset &rsOperDefn = CreateRowset(Record.PSOPRDEFN);
&rsOperDefn.Fill("WHERE OPRID = 'PS'");
&oJson.AddRowset("MyRowset", &rsOperDefn);
Use the AddProperty
method if you are unsure of the data or object type.
Local any &aValue = CreateArrayAny("test", True, 6, Null);
If Int(Rand() * 10) > 5 Then
&aValue = Null;
End-If;
&oJson.AddProperty("MyProperty", &aValue);
Invoke the ToJsonString
method to get the JSON String output.
Local String &sOutput = &oJson.ToJsonString();
See the JSON Object section to view all of the available methods and properties.
Use the PSM_JSON:Array
Class to build JSON Arrays.
Local PSM_JSON:Array &oJson = create PSM_JSON:Array();
The various AddXxx
methods allow you to add PeopleCode object types to the JSON Array.
Local Record &rPsOptions = CreateRecord(Record.PSOPTIONS);
&rPsOptions.SelectByKey();
&oJson.AddRecord(&rPsOptions);
Use the AddElement
method if you are unsure of the data or object type.
Local any &aValue = %Request;
If Int(Rand() * 10) > 5 Then
&aValue = %Response;
End-If;
&oJson.AddElement(&aValue);
Invoke the ToJsonString
method to get the JSON String output.
Local String &sOutput = &oJson.ToJsonString();
See the JSON Array section to view all of the available methods and properties.
Use the PSM_JSON:Node
Class to build JSON Nodes.
Local PSM_JSON:Node &oJson = create PSM_JSON:Node();
The various SetXxx
methods allow you convert PeopleCode object types to a JSON Node.
Local PTPP_COLLECTIONS:Shortcut &oCref;
&oCref = create PTPP_COLLECTIONS:Shortcut(%Portal, "PT_CHANGE_PASSWORD_GBL");
&oJson.SetClass(&oCref);
Invoke the ToJsonString
method to get the JSON String output.
Local String &sOutput = &oJson.ToJsonString();
See the JSON Node section to view all of the available methods and properties.
Note: Not all PeopleCode object types are supported. ToJsonString
will return the object type name as a String if you use an unsupported type.