camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "james strachan (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-10646) support JSONPath on beans as well as Strings & InputStreams
Date Fri, 23 Dec 2016 13:28:58 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-10646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15772901#comment-15772901
] 

james strachan commented on CAMEL-10646:
----------------------------------------

awesome thanks!

> support JSONPath on beans as well as Strings & InputStreams
> -----------------------------------------------------------
>
>                 Key: CAMEL-10646
>                 URL: https://issues.apache.org/jira/browse/CAMEL-10646
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-jsonpath
>            Reporter: james strachan
>            Assignee: Claus Ibsen
>             Fix For: 2.19.0
>
>
> it'd be nice if we could use json path expressions on beans too; so that if some JSON
gets unmarshalled via jackson we could still use jsonPath on the object.
> Here's a possible implementation approach (though maybe there's a more optimal approach?)
> http://stackoverflow.com/a/27754489/2068211
> Maybe this code https://github.com/apache/camel/blob/master/components/camel-jsonpath/src/main/java/org/apache/camel/jsonpath/JsonPathEngine.java#L114
should check if the body can't be converted to a File, String or InputStream it tries to convert
the payload to something like JSonPathNavigator (a new interface we create). If it can be
converted we use that interface to transform the payload.
> Then we could have decoupled ways to convert objects into navigable formats (e.g. Maps
/ Lists)?
> e.g. 
> {code:java}
> public JacksonJsonPathNavigator implements JSonPathNavigator {
>   public Object convert(Object input) {
>     ObjectMapper mapper = new ObjectMapper();
>     return mapper.convertValue(input, Map.class);
>   }
> }
> {code}
> This is how we've used saxon in the past with different libraries to perform XPath navigation
(e.g. c24 stuff). 
> Another approach could just be to try convert the object to a Map and have a Jackson
based converter that can convert objects with a Jackon annotation to a Map using the above
code?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message