UniPRT SDK  v1.0.0.0
com.UniPRT.Sdk.Json.JsonStringTokenizer Class Reference

Support for parsing JSON msgs from printer. More...

Static Public Member Functions

static boolean HasKey (String key, String jsonStr)
 Check if msg contains "key" e.g. HasKey("Content", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":...}");. More...
 
static boolean HasKeyAtPath (String keyPath, String jsonStr)
 Check if msg contains path to key e.g. HasKeyPath("Content.Item1", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":{"item1":"<value1>",..</value1>} , ...}");. More...
 
static String GetKeyValue (String key, String jsonStr)
 Get key value as string, empty ("") string if key not found e.g. get "<value1>", GetKeyAtPath("Content.Item1", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":{"item1":"<value1>",..</value1>} , ...}");. More...
 
static String GetKeyValueAtPath (String keyPath, String jsonStr)
 Get key value as string, empty ("") string if key not found e.g. get "<value1>", GetKeyAtPath("Content.Item1", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":{"item1":"<value1>",..</value1>} , ...}");. More...
 
static Map< String, String > GetKeyValuePairsFromElementList_Json (String elemName, String jsonData)
 Retrieve dictionary containing key/value pairs within list of objects. More...
 
static boolean IsSolicitedMsg_Json (String msgStr)
 Check if msg is a solicted msg (response to a query sent to printer) More...
 
static boolean IsCmdSuccess (String msgStr)
 Check if msg is "Success" (response to a query sent to printer) More...
 
static String GetMsgId_Json (String msgStr)
 retrieve the "To" key value in the msg element. returns emptyr ("") if no "To" key present More...
 
static String GetMsgIdExpectedOnResponse_Json (String msgStr)
 retrieve the "From" expected for the response to the msg passed in. e.g. handles case where "From" will be empty ("") if no "From" key in msg passed in More...
 

Static Private Attributes

static ObjectMapper mapper = new ObjectMapper()
 

Detailed Description

Support for parsing JSON msgs from printer.

Member Function Documentation

◆ GetKeyValue()

static String com.UniPRT.Sdk.Json.JsonStringTokenizer.GetKeyValue ( String  key,
String  jsonStr 
)
static

Get key value as string, empty ("") string if key not found e.g. get "<value1>", GetKeyAtPath("Content.Item1", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":{"item1":"<value1>",..</value1>} , ...}");.

Note that "keyPath" could be dot delimted based on Json Path notation
e.g. "Content" and "Content.Item1" are different paths. First one checks for existence of "Content" and second one checks for existence of "item1" within "Content"

References com.UniPRT.Sdk.Json.JsonStringTokenizer.mapper.

Referenced by com.UniPRT.Sdk.Settings.Config.Config(), com.UniPRT.Sdk.Json.SettingsReadWrite.GetAllProperties(), com.UniPRT.Sdk.Settings.Configs.GetConfig(), com.UniPRT.Sdk.Json.JsonStringTokenizer.GetKeyValuePairsFromElementList_Json(), com.UniPRT.Sdk.Json.JsonStringTokenizer.GetMsgId_Json(), com.UniPRT.Sdk.Json.JsonStringTokenizer.GetMsgIdExpectedOnResponse_Json(), com.UniPRT.Sdk.Json.SettingsReadWrite.GetProperties(), com.UniPRT.Sdk.Json.JsonStringTokenizer.IsCmdSuccess(), com.UniPRT.Sdk.Mgmt.MgmtMsg.MgmtMsg(), com.UniPRT.Sdk.Json.OdvMonitor.MsgListenerCtrlRefresh(), com.UniPRT.Sdk.Json.RfidMonitor.MsgListenerCtrlRefresh(), and com.UniPRT.Sdk.Json.PrinterMonitor.MsgListenerCtrlRefresh().

◆ GetKeyValueAtPath()

static String com.UniPRT.Sdk.Json.JsonStringTokenizer.GetKeyValueAtPath ( String  keyPath,
String  jsonStr 
)
static

Get key value as string, empty ("") string if key not found e.g. get "<value1>", GetKeyAtPath("Content.Item1", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":{"item1":"<value1>",..</value1>} , ...}");.

Note that "keyPath" could be dot delimted based on Json Path notation
e.g. "Content" and "Content.Item1" are different paths. First one checks for existence of "Content" and second one checks for existence of "item1" within "Content"

References com.UniPRT.Sdk.Json.JsonStringTokenizer.mapper.

Referenced by com.UniPRT.Sdk.Json.PrinterMonitor.GetEngineStatus(), com.UniPRT.Sdk.Json.PrinterMonitor.GetFaultStatus(), and com.UniPRT.Sdk.Json.PrinterMonitor.MsgListenerCtrlRefresh().

◆ GetKeyValuePairsFromElementList_Json()

static Map<String, String> com.UniPRT.Sdk.Json.JsonStringTokenizer.GetKeyValuePairsFromElementList_Json ( String  elemName,
String  jsonData 
)
static

Retrieve dictionary containing key/value pairs within list of objects.


elemName: the element to convert to dictionary or empty ("") string if want entire string converted to dictionary jsonData: the JSON string

e.g. { "item1": "value1", "item2": null, "item3": true, ... "itemN":"valueN" } Dict key = JSON key, e.g. "item1" Dict value = JSON value e.g. "value1"

e.g. GetKeyValueFromElementList("Content", jsonData) where jsonData = { "root1": "rootVal1", "Content": { "item1": "value1", "item2": null }} resulst in dictionary w/ 2 entries: key="item1" value="value1", key="item2" value="null"

e.g. GetKeyValueFromElementList("", jsonData) where jsonData = { "root1": "rootVal1", "Content": "someContent"} resulst in dictionary w/ 2 entries: key="root1" value="rootVal1", key="Content" value="someContent"

References com.UniPRT.Sdk.Json.JsonStringTokenizer.GetKeyValue(), and com.UniPRT.Sdk.Json.JsonStringTokenizer.mapper.

Referenced by com.UniPRT.Sdk.Json.SettingsReadWrite.GetAllValues(), com.UniPRT.Sdk.Json.SettingsReadWrite.GetValue(), com.UniPRT.Sdk.Json.SettingsReadWrite.GetValues(), com.UniPRT.Sdk.Json.OdvMonitor.MsgParser_OdvReport(), com.UniPRT.Sdk.Json.PrinterMonitor.MsgParser_PrinterInfo(), and com.UniPRT.Sdk.Json.RfidMonitor.MsgParser_RfidReport().

◆ GetMsgId_Json()

static String com.UniPRT.Sdk.Json.JsonStringTokenizer.GetMsgId_Json ( String  msgStr)
static

◆ GetMsgIdExpectedOnResponse_Json()

static String com.UniPRT.Sdk.Json.JsonStringTokenizer.GetMsgIdExpectedOnResponse_Json ( String  msgStr)
static

retrieve the "From" expected for the response to the msg passed in. e.g. handles case where "From" will be empty ("") if no "From" key in msg passed in

References com.UniPRT.Sdk.Json.JsonStringTokenizer.GetKeyValue().

Referenced by com.UniPRT.Sdk.Json.OdvMonitor.MsgListenerCtrlRefresh(), com.UniPRT.Sdk.Json.RfidMonitor.MsgListenerCtrlRefresh(), and com.UniPRT.Sdk.Json.JsonComm.SendAndWaitForResponse().

◆ HasKey()

static boolean com.UniPRT.Sdk.Json.JsonStringTokenizer.HasKey ( String  key,
String  jsonStr 
)
static

Check if msg contains "key" e.g. HasKey("Content", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":...}");.

Note that "key" is NOT parsed as Json Path notation e.g. "Command" and "Command.SubCmd.SubSubCmd" are both valid

References com.UniPRT.Sdk.Json.JsonStringTokenizer.mapper.

◆ HasKeyAtPath()

static boolean com.UniPRT.Sdk.Json.JsonStringTokenizer.HasKeyAtPath ( String  keyPath,
String  jsonStr 
)
static

Check if msg contains path to key e.g. HasKeyPath("Content.Item1", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":{"item1":"<value1>",..</value1>} , ...}");.

Note that "keyPath" could be dot delimted as based on Json Path notation
e.g. "Content" and "Content.Item1" are different paths. First one checks for existence of "Content" and second one checks for existence of "item1" within "Content"

References com.UniPRT.Sdk.Json.JsonStringTokenizer.mapper.

Referenced by com.UniPRT.Sdk.Json.JsonStringTokenizer.IsSolicitedMsg_Json(), and com.UniPRT.Sdk.Json.PrinterMonitor.MsgListenerCtrlRefresh().

◆ IsCmdSuccess()

static boolean com.UniPRT.Sdk.Json.JsonStringTokenizer.IsCmdSuccess ( String  msgStr)
static

◆ IsSolicitedMsg_Json()

static boolean com.UniPRT.Sdk.Json.JsonStringTokenizer.IsSolicitedMsg_Json ( String  msgStr)
static

Check if msg is a solicted msg (response to a query sent to printer)

References com.UniPRT.Sdk.Json.JsonStringTokenizer.HasKeyAtPath().

Member Data Documentation

◆ mapper


The documentation for this class was generated from the following file: