我对 Apama 比较陌生。我正在使用 v10.3.1。我正在按照以下代码段在监视器中执行 REST 请求:
当前处理响应的操作如下所示:
action handleResponse(Response response){
if response.isSuccess(){
print "###The response payload is :" + response.payload.toString();
}
else {
print "###Request failed. Response status is: " + response.statusCode.toString() + " | " + response.statusMessage;
}
}
我正在寻找在 JSON 响应负载中提取以下属性值的最佳方法:
assetparents.references[0].managedObject.name (here “SOME”).
我尝试了不同的方法,但总是遇到错误。
print 语句为响应负载提供以下输出:
###The response payload is :com.apama.util.AnyExtractor(any(string,"
{"owner":"some@one.com","additionParents":{
"self":"https://somebaseurl/inventory/managedObjects/5706999/additionParents","references":[]
},
"childDevices":{
"self":"https://somebaseurl/inventory/managedObjects/5706999/childDevices","references":[]
},
"childAssets":{
"self":"https://somebaseurl/inventory/managedObjects/5706999/childAssets","references":[]
},
"creationTime":"2019-05-09T11:36:10.197Z",
"lastUpdated":"2019-05-10T05:28:07.893Z",
"childAdditions":{
"self":"https://somebaseurl/inventory/managedObjects/5706999/childAdditions",
"references":[{
"managedObject":{"name":"Escalate alarmtest",
"self":"https://somebaseurl/inventory/managedObjects/5706698",
"id":"5706698"},
"self":"https://somebaseurl/inventory/managedObjects/5706999/childAdditions/5706698"
}
]},
"name":"SOME Test Device",
"deviceParents":{
"self":"https://somebaseurl/inventory/managedObjects/5706999/deviceParents",
"references":[]
},
"assetParents":{
"self":"https://somebaseurl/inventory/managedObjects/5706999/assetParents",
"references":[{
"managedObject":{
"additionParents":{
"self":"https://somebaseurl/inventory/managedObjects/5706682/additionParents",
"references":[]
},
"childDevices":{
"self":"https://somebaseurl/inventory/managedObjects/5706682/childDevices",
"references":[]
},
"childAssets":{
"self":"https://somebaseurl/inventory/managedObjects/5706682/childAssets",
"references":[]
},
"childAdditions":{
"self":"https://somebaseurl/inventory/managedObjects/5706682/childAdditions",
"references":[]
},
"name":"SOME",
"deviceParents":{
"self":"https://somebaseurl/inventory/managedObjects/5706682/deviceParents",
"references":[]
},
"assetParents":{
"self":"https://somebaseurl/inventory/managedObjects/5706682/assetParents",
"references":[]
},
"self":"https://somebaseurl/inventory/managedObjects/5706682",
"id":"5706682"
},
"self":"https://somebaseurl/inventory/managedObjects/5706999/assetParents/5706682"
}]
},
"self":"https://somebaseurl/inventory/managedObjects/5706999",
"id":"5706999",
"c8y_ActiveAlarmsStatus":{
"minor":0,
"critical":1
},
"c8y_IsDevice":{},
"ax_Customer":"SOME CUSTOMER",
"c8y_SupportedMeasurements":["c8y_Temperature"]}"))
除了解析单个属性之外,将整个对象映射到 Apama 事件的推荐方法是什么?
如果您能提供代码片段,将不胜感激。
非常感谢马蒂亚斯