我正在尝试使用以下Clode从JSON数据流生成JSON对象:
@sink(type='log')
define stream TempStream(designation object);
from TestStream
select json:setElement("{}", "$", json:getString(json,"$.DESIGNATION"), "designation") as designation
insert into TempStream;
但是输出数据具有空值。请问代码有什么问题吗?
TempStream : Event{timestamp=1554192487415, data=[null], isExpired=false}
具有如下所示传递数据的输入流:
TestStream : Event{timestamp=1554192487415, data=[{"STATUS":"AA","CREATED_DATE":"2010-11-23 10:24:36","DESIGNATION":"Manager"}], isExpired=false}
答案 0 :(得分:1)
我已经在SP 4.3.0软件包上进行了检查,并得到了以下结果
SiddhiApp : TempStream : Event{timestamp=1554733451717, data=[{designation=Manager}], isExpired=false}
对于发送到“ TestStream ”的事件,我使用的查询如下,
@sink(type='log',"TEMPSTREAM")
define stream TempStream(designation object);
@sink(type='log')
define stream TestStream(json string);
from TestStream
select json:setElement("{}", "$", json:getString(json,"$.DESIGNATION"), "designation") as designation
insert into TempStream;
SiddhiApp : TestStream : Event{timestamp=1554733451717, data=[{ "STATUS": "AA", "CREATED_DATE": "2010-11-23 10:24:36", "DESIGNATION": "Manager" } ], isExpired=false}
我相信这是您所期望的结果。