支援解析來自打印機的 JSON 讯息 更多...
靜態公開方法(Static Public Methods) | |
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 更多... | |
靜態私有屬性 | |
static ObjectMapper | mapper = new ObjectMapper() |
支援解析來自打印機的 JSON 讯息
|
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().
|
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().
|
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().
|
static |
retrieve the "To" key value in the msg element. returns emptyr ("") if no "To" key present
參考 com.UniPRT.Sdk.Json.JsonStringTokenizer.GetKeyValue().
被參考於 com.UniPRT.Sdk.Json.PrinterMonitor.MsgListenerCtrlRefresh(), com.UniPRT.Sdk.Json.JsonComm.SendAndWaitForMsgFrame(), 及 com.UniPRT.Sdk.Json.JsonComm.SendAndWaitForResponse().
|
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().
|
static |
檢查讯息是否包含「key」,例如:HasKey("Content", "{ "Command": "DoThisOrThat", "To": "SomeTgt", "From": "SomeDevice", "Content":...}");
注意:「key」不會被解析為 JSON 路徑標記法 例如:「Command」和「Command.SubCmd.SubSubCmd」皆為有效值
|
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().
|
static |
Check if msg is "Success" (response to a query sent to printer)
參考 com.UniPRT.Sdk.Json.JsonStringTokenizer.GetKeyValue().
被參考於 com.UniPRT.Sdk.Settings.Configs.GetConfig(), com.UniPRT.Sdk.Settings.Configs.SetConfig(), com.UniPRT.Sdk.Json.SettingsReadWrite.SetValue(), 及 com.UniPRT.Sdk.Json.SettingsReadWrite.SetValues().
|
static |
Check if msg is a solicted msg (response to a query sent to printer)
|
staticprivate |
被參考於 com.UniPRT.Sdk.Json.JsonStringTokenizer.GetKeyValue(), com.UniPRT.Sdk.Json.JsonStringTokenizer.GetKeyValueAtPath(), com.UniPRT.Sdk.Json.JsonStringTokenizer.GetKeyValuePairsFromElementList_Json(), com.UniPRT.Sdk.Json.JsonStringTokenizer.HasKey(), 及 com.UniPRT.Sdk.Json.JsonStringTokenizer.HasKeyAtPath().