Thanks I will try this. However I'm still a bit surprised over the way that the unmarshal add the full name of the POJO class to the JSON. Not very convenient when sending data to a external system where I do not have any control over the logic.
Not sure if this is an issue only when useList="true" or if unmarshaling a separate POJO will also add this data. // Pontus On Wed, 3 Jun 2015 at 10:28 Henryk Konsek <[email protected]> wrote: > Hi, > > IMHO We should ignore unknown fields in Jackson by default: > > objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, > false); > > This is the essential option for Jackson, as JSON is usually not as strict > as XML. I would say that we should add failOnUnknownProperties options to > Jackson data format and default it to 'false'. What do you think? > > Cheers! > > PS Pontus, you can set the option on the object mapper by yourself as a > workaround. > > wt., 2.06.2015 o 22:32 użytkownik Pontus Ullgren <[email protected]> > napisał: > > > Hi, > > > > I'm trying to build a solution when I marshal POJO into JSON and send > over > > JMS to a remote machine. On the remote machine message is also consumed > by > > a Camel route. > > > > However the JSON on the remote machine is unable to marshal the JSON that > > the dataformater created. > > > > To show the error I created a smaller POC where I use a SEDA within the > > same camel context and it shows the same error. > > Here is the test project https://bitbucket.org/ullgren/jsonmarshaltest > > > > It seems that the unmarshal does not like the fact that the POJO class > name > > is added as a field. Is there anyway to change this behaviour, > > > > The error I get is: > > > > [/jsonmarshaltest.sendToBackend] SedaConsumer WARN > Error > > processing exchange. Exchange[Message: > > [{"com.ullgren.pontus.example.model.Order":{"id":"1","customerName":"Joe > > Doe","customerEmail":"[email protected] > > > ","productNo":"ABC123","amount":"10","dispatched":false}},{"com.ullgren.pontus.example.model.Order":{"id":"2","customerName":"Elmer > > Fudd","customerEmail":"[email protected] > > > ","productNo":"GUN12G","amount":"2","dispatched":false}},{"com.ullgren.pontus.example.model.Order":{"id":"3","customerName":"Porky > > Pig","customerEmail":"[email protected] > > > ","productNo":"STU3","amount":"8","dispatched":false}},{"com.ullgren.pontus.example.model.Order":{"id":"4","customerName":"Foghorn > > J. Leghorn","customerEmail":"[email protected] > > > ","productNo":"CORN961","amount":"10","dispatched":false}},{"com.ullgren.pontus.example.model.Order":{"id":"5","customerName":"Wile > > E. Coyote","customerEmail":"[email protected] > > ","productNo":"BOM44","amount":"100","dispatched":false}}]]. > > Caused by: > > [com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException - > > Unrecognized field "com.ullgren.pontus.example.model.Order" (class > > com.ullgren.pontus.example.model.Order), not marked as ignorable (6 known > > properties: "productNo", "amount", "customerName", "dispatched", "id", > > "customerEmail"]) > > at [Source: java.io.ByteArrayInputStream@506208e4; line: 1, column: 45] > > (through reference chain: > > > > > com.ullgren.pontus.example.model.Order["com.ullgren.pontus.example.model.Order"])] > > com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: > > Unrecognized field "com.ullgren.pontus.example.model.Order" (class > > com.ullgren.pontus.example.model.Order), not marked as ignorable (6 known > > properties: "productNo", "amount", "customerName", "dispatched", "id", > > "customerEmail"]) > > at [Source: java.io.ByteArrayInputStream@506208e4; line: 1, column: 45] > > (through reference chain: > > > > > com.ullgren.pontus.example.model.Order["com.ullgren.pontus.example.model.Order"]) > > at > > > > > com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:51) > > at > > > > > com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:731) > > at > > > > > com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:915) > > at > > > > > com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1292) > > at > > > > > com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1270) > > at > > > > > com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:247) > > at > > > > > com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:118) > > at > > > > > com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:232) > > at > > > > > com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:206) > > at > > > > > com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:25) > > at > > > > > com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3051) > > at > > > > > com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2206) > > at > > > > > org.apache.camel.component.jackson.JacksonDataFormat.unmarshal(JacksonDataFormat.java:126) > > at > > > > > org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:67) > > at > > > > > org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163) > > at > > > > > org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:424) > > at > > > > > org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) > > at org.apache.camel.processor.Pipeline.process(Pipeline.java:118) > > at org.apache.camel.processor.Pipeline.process(Pipeline.java:80) > > at > > > > > org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) > > at > > > > > org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:291) > > at > > org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:200) > > at > org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:147) > > at > > > > > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) > > at > > > > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) > > at java.lang.Thread.run(Thread.java:745) > > > > Thanks > > Pontus Ullgren > > >
