java.lang.Object
edu.internet2.ndt.JSONUtils
Utility class for JSON object manipulation and message handling.
Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionstatic StringaddValueToJsonObj(String jsonTxt, String key, String value) Function that add new value to JSON map.static byte[]createJsonLoginObj(byte[] msg, byte tests) Function that return json object represented by jsontext and included single message assigned to "msg" key.static byte[]createJsonObj(byte[] msg) Function that return json object represented by jsontext and included single message assigned to "msg" key.static StringgetSingleMessage(String jsonTxt) Function that return value from json object represented by jsontext containing a single message which is assigned to "msg" key.static StringgetValueFromJsonObj(String jsonTxt, String key) Function that return value for given key from json object represented by jsontext.
Constructor Details
JSONUtils
public JSONUtils()Constructor. Each helper parses the JSON text it is handed and returns a value, so an instance carries no state.
Method Details
getSingleMessage
getValueFromJsonObj
addValueToJsonObj
Function that add new value to JSON map.- Parameters:
jsonTxt- {String} JSON objectkey- {String} key by which value should be assigned to JSON mapvalue- {String} value for given key- Returns:
- {String} json object with added value.
createJsonObj
public static byte[] createJsonObj(byte[] msg) Function that return json object represented by jsontext and included single message assigned to "msg" key.- Parameters:
msg- {byte[]} message which should be assigned to json object- Returns:
- {byte[]} json object represented by jsontext and encodes into a sequence of bytes
createJsonLoginObj
public static byte[] createJsonLoginObj(byte[] msg, byte tests) Function that return json object represented by jsontext and included single message assigned to "msg" key.- Parameters:
msg- {byte[]} message which should be assigned to json objecttests- the test IDs whose results should be included- Returns:
- {byte[]} json object represented by jsontext and encodes into a sequence of bytes