By calling a service over http , the response which i am getting is of
format:

[{"a":1,"b":2,"c":3},{"a":4,"b":5,"c":6}]

So to map this i have 

public void configure() { 
                    from("direct:ab") 
                       .setHeader(HTTP_URI, simple(baseUrl +
"/${header.aa}"))                      
.to("http://dummyhost";).unmarshal().json(JsonLibrary.Jackson,CustomList.class).to("bean:com.xxx.MyMsgProcessor?method=process");
 
                } 

My CustomList is 

public class CustomList {
    List<SimpleBean> simpleBeanList;


    public List<SimpleBean> getSimpleBeanList() {
        return simpleBeanList;
    }


    public void setSimpleBeanList(List<SimpleBean> simpleBeanList) {
        this.simpleBeanList = simpleBeanList;
    }
}

SimpleBean.java

public class SimpleBean {

    private  String a;
    private  String b;
    private  String c;

    public String getA() {
        return a;
    }

    public void setA(String a) {
        this.a= a;
    }

    public String getB() {
        return b;
    }

    public void setB(String b) {
        this.b= b;
    }

    public String getC() {
        return c;
    }


    public void setC(String c) {
        this.c= c;
    }

}


SO now i am getting an exception 

com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize
instance of com.xx.CustomList out of START_ARRAY token


I also tried using the same logic of creating a beans 
for
url:http://maps.googleapis.com/maps/api/geocode/json?address=Winnetka&sensor=false&key=API_KEY

the response is {
   "error_message" : "Requests to this API must be over SSL.",
   "results" : [],
   "status" : "REQUEST_DENIED"
}

so for tranforimg this i have created ErrorBean with
error_message,results(List<String>),status with setters and getters
Route:
public void configure() { 
                    from("direct:ab") 
                       .setHeader(HTTP_URI, simple(baseUrl +
"/${header.aa}"))                      
.to("http://dummyhost";).unmarshal().json(JsonLibrary.Jackson,ErrorBean.class).to("bean:com.xxx.MyMsgProcessor?method=process");
 
                } 
In this case i am able to get the response.

So how to we map responses like 
[{"a":1,"b":2,"c":3},{"a":4,"b":5,"c":6}] where there is not root elements?

I have looked into one of discussion in which we have similar problem but it
was not clear enough for me
understand(http://camel.465427.n5.nabble.com/JSON-Jackson-return-list-rather-than-POJO-td5717341.html)
      



--
View this message in context: 
http://camel.465427.n5.nabble.com/DataFormat-Versus-TypeConverters-tp5747307p5747369.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to