Camel:JSonPath似乎在执行搜索时改变了上下文

时间:2016-01-21 12:38:05

标签: json apache-camel jsonpath

有一些JSON:

{
  metadata:{
    result_count: 3,
  },

  search_results: [
   {...},
   {...},
   {...}
  ]
}

做的时候

.setHeader("result_count").jsonpath("$.metadata.result_count")
.setHeader("result").jsonpath("$.search_results[0]")

获得

Caused by: com.jayway.jsonpath.PathNotFoundException: Property ['search_results'] not found in path $

更改订单时:

.setHeader("result").jsonpath("$.search_results[0]")
.setHeader("result_count").jsonpath("$.metadata.result_count")

获得

Caused by: com.jayway.jsonpath.PathNotFoundException: Property ['metadata'] not found in path $

如何解决?

0 个答案:

没有答案