从骆驼交换到Java对象的迭代/获取数据
在项目流中,我正在以Apache Camel Exchange中的JSON Collection的形式获取数据,并进一步处理它,我需要在Java对象中进行转换,
try{
List<RespModel> records = (List<RespModel>) exchange.getIn().getBody(RespModel.class);
System.out.println(records.size());
}catch (Exception e){
System.out.println("NO LUCK "+e.getLocalizedMessage());
}
但我将记录视为null。 您能帮我改变吗?
交换数据如下 -
"identifier": {
"domain": "transport",
"id": "123",
"version": 1
},
"record": "NEW",
"payload": {
"pesonalDetails" : {
"name" : "bla bla bla"
"dob" :
},
"reason" :
}
},{
"identifier": {
"domain": "transport",
"id": "123",
"version": 1
},
"record": "NEW",
"payload": {
"pesonalDetails" : {
"name" : "bla bla bla"
"dob" :
},
"reason" :
}]```
I am getting null here, how can i achieve this ? pls reply if you know. Thanks
In the project flow i am getting the data in form of json collection in apache camel exchange and to process it further i need to transform it in java object
try{
List<RespModel> records = (List<RespModel>) exchange.getIn().getBody(RespModel.class);
System.out.println(records.size());
}catch (Exception e){
System.out.println("NO LUCK "+e.getLocalizedMessage());
}
But i am getting records as null.
Could you please help me to transform this ?
exchange data is as below -
"identifier": {
"domain": "transport",
"id": "123",
"version": 1
},
"record": "NEW",
"payload": {
"pesonalDetails" : {
"name" : "bla bla bla"
"dob" :
},
"reason" :
}
},{
"identifier": {
"domain": "transport",
"id": "123",
"version": 1
},
"record": "NEW",
"payload": {
"pesonalDetails" : {
"name" : "bla bla bla"
"dob" :
},
"reason" :
}]```
I am getting null here, how can i achieve this ? pls reply if you know. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最终得到答案 -
Got the answer finally -