camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Vila Lopez <jonathan.v...@gmail.com>
Subject Simple and easy REST client with Camel
Date Sun, 26 Oct 2014 23:25:49 GMT
Hello

I have a very simple problem to solve but I've not been capable of sorting
out.

Have one REST remote webservice from Marvel, and would like to create a
route that calls that webservice, gets the JSon response, and finally
prints out 3 of its attributes.

One told me the easiest approach would be to use an HTTP adapter and then a
json component.

This is what I have for now :

                from("
http://gateway.marvel.com:80/v1/public/comics?dateDescriptor=nextWeek&ts=987&apikey=97f295907072a970c5df30d73d1f3816&hash=abfa1c1d42a73a5eab042242335d805d
").
                        unmarshal().json(JsonLibrary.Jackson).
                        setBody(simple("my attributes are :
${body?.code?}")).
                        to("stream:out");

But in the setBody line I dont get anything.....

The structure of the JSON is like this :

{
  "code": "int",
  "status": "string",
  "data": {
    "offset": "int",
    "limit": "int",
    "total": "int",
    "results": [
      {
        "id": "int",
        "digitalId": "int",
        "title": "string",
        "description": "string",
        "prices": [
          {
            "type": "string",
            "price": "float"
          }
        ],
        "thumbnail": {
          "path": "string",
          "extension": "string"
        } ] }
}

And I would like to get the values for "code", "data.results.title",
"data.results.prices.price", "data.results.thumbnail.path"

Any help ?


[image: Inline image 2]

* Jonathan Vila    ** <https://www.twitter.com/jonathan_vila>
<http://www.linkedin.com/in/jonathanvila>*


* jonathan.vila@gmail.com <jonathan.vila@gmail.com>*

Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message