UniPRT SDK  v1.0.0.0
com.UniPRT.Sdk.Json.JsonStringTokenizer类 参考

支持解析来自印表机的 JSON 讯息 更多...

静态 Public 成员函数

static boolean HasKey (String key, String jsonStr)
 检查讯息是否包含“key”,例如:HasKey("Content", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":...}"); 更多...
 
static boolean HasKeyAtPath (String keyPath, String jsonStr)
 检查讯息是否包含通往“key”的路径,例如:HasKeyPath("Content.Item1", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":{"item1":"<value1>",..</value1>} , ...}"); 更多...
 
static String GetKeyValue (String key, String jsonStr)
 以字符串形式获取 key 的值,如果 key 不存在则返回空字符串 (""),例如:获取 "<value1>", GetKeyAtPath("Content.Item1", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":{"item1":"<value1>",..</value1>} , ...}"); 更多...
 
static String GetKeyValueAtPath (String keyPath, String jsonStr)
 以字符串形式获取 key 的值,如果 key 不存在则返回空字符串 (""),例如:获取 "<value1>", GetKeyAtPath("Content.Item1", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":{"item1":"<value1>",..</value1>} , ...}"); 更多...
 
static Map< String, String > GetKeyValuePairsFromElementList_Json (String elemName, String jsonData)
 获取包含对象列表中 key/value 对应的字典。 更多...
 
static boolean IsSolicitedMsg_Json (String msgStr)
 Check if msg is a solicted msg (response to a query sent to printer) 更多...
 
static boolean IsCmdSuccess (String msgStr)
 Check if msg is "Success" (response to a query sent to printer) 更多...
 
static String GetMsgId_Json (String msgStr)
 retrieve the "To" key value in the msg element. returns emptyr ("") if no "To" key present 更多...
 
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 更多...
 

静态 Private 属性

static ObjectMapper mapper = new ObjectMapper()
 

详细描述

支持解析来自印表机的 JSON 讯息

成员函数说明

◆ GetKeyValue()

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

以字符串形式获取 key 的值,如果 key 不存在则返回空字符串 (""),例如:获取 "<value1>", GetKeyAtPath("Content.Item1", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":{"item1":"<value1>",..</value1>} , ...}");

注意:“keyPath”可能以点分隔,基于 JSON 路径标记法
例如:“Content”和“Content.Item1”为不同路径。前者检查“Content”是否存在,后者检查“Content”内的“item1”是否存在

引用了 com.UniPRT.Sdk.Json.JsonStringTokenizer.mapper.

被这些函数引用 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() , 以及 com.UniPRT.Sdk.Json.PrinterMonitor.MsgListenerCtrlRefresh().

◆ GetKeyValueAtPath()

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

以字符串形式获取 key 的值,如果 key 不存在则返回空字符串 (""),例如:获取 "<value1>", GetKeyAtPath("Content.Item1", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":{"item1":"<value1>",..</value1>} , ...}");

注意:“keyPath”可能以点分隔,基于 JSON 路径标记法
例如:“Content”和“Content.Item1”为不同路径。前者检查“Content”是否存在,后者检查“Content”内的“item1”是否存在

引用了 com.UniPRT.Sdk.Json.JsonStringTokenizer.mapper.

被这些函数引用 com.UniPRT.Sdk.Json.PrinterMonitor.GetEngineStatus(), com.UniPRT.Sdk.Json.PrinterMonitor.GetFaultStatus() , 以及 com.UniPRT.Sdk.Json.PrinterMonitor.MsgListenerCtrlRefresh().

◆ GetKeyValuePairsFromElementList_Json()

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

获取包含对象列表中 key/value 对应的字典。


elemName:欲转换为字典的元素名称,若为空 ("") 字符串则将整个 JSON 字符串转换为字典 jsonData:JSON 字符串

例如:{ "item1": "value1", "item2": null, "item3": true, ... "itemN":"valueN" } 字典 key = JSON key,例如 "item1" 字典 value = JSON value,例如 "value1"

例如:GetKeyValueFromElementList("Content", jsonData) 其中 jsonData = { "root1": "rootVal1", "Content": { "item1": "value1", "item2": null }} 结果为含有 2 个项目的字典:key="item1" value="value1", key="item2" value="null"

例如:GetKeyValueFromElementList("", jsonData) 其中 jsonData = { "root1": "rootVal1", "Content": "someContent"} 结果为含有 2 个项目的字典:key="root1" value="rootVal1", key="Content" value="someContent"

引用了 com.UniPRT.Sdk.Json.JsonStringTokenizer.GetKeyValue() , 以及 com.UniPRT.Sdk.Json.JsonStringTokenizer.mapper.

被这些函数引用 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() , 以及 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

引用了 com.UniPRT.Sdk.Json.JsonStringTokenizer.GetKeyValue().

被这些函数引用 com.UniPRT.Sdk.Json.OdvMonitor.MsgListenerCtrlRefresh(), com.UniPRT.Sdk.Json.RfidMonitor.MsgListenerCtrlRefresh() , 以及 com.UniPRT.Sdk.Json.JsonComm.SendAndWaitForResponse().

◆ HasKey()

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

检查讯息是否包含“key”,例如:HasKey("Content", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":...}");

注意:“key”不会被解析为 JSON 路径标记法 例如:“Command”和“Command.SubCmd.SubSubCmd”皆为有效值

引用了 com.UniPRT.Sdk.Json.JsonStringTokenizer.mapper.

◆ HasKeyAtPath()

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

检查讯息是否包含通往“key”的路径,例如:HasKeyPath("Content.Item1", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":{"item1":"<value1>",..</value1>} , ...}");

注意:“keyPath”可能以点分隔,基于 JSON 路径标记法
例如:“Content”和“Content.Item1”为不同路径。前者检查“Content”是否存在,后者检查“Content”内的“item1”是否存在

引用了 com.UniPRT.Sdk.Json.JsonStringTokenizer.mapper.

被这些函数引用 com.UniPRT.Sdk.Json.JsonStringTokenizer.IsSolicitedMsg_Json() , 以及 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)

引用了 com.UniPRT.Sdk.Json.JsonStringTokenizer.HasKeyAtPath().

类成员变量说明

◆ mapper


该类的文档由以下文件生成: