You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/04/15 09:22:22 UTC

[GitHub] [camel-k] senayuki opened a new issue, #3212: Cant specify fastjson when marshal

senayuki opened a new issue, #3212:
URL: https://github.com/apache/camel-k/issues/3212

   I trying to use fastjson instance of jackson, so I wrote this yaml
   ```yaml
   apiVersion: camel.apache.org/v1
   kind: Integration
   metadata:
     name: jackson-test
     namespace: camel
   spec:
     dependencies:
     - mvn:mysql:mysql-connector-java:8.0.28
     - mvn:org.apache.commons:commons-dbcp2:2.8.0
     - mvn:com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.2
     flows:
     - from:
         steps:
         - to:
             uri: freemarker:sql.ftl?contentCache=false
         - to:
             uri: (hidden bean)
         - marshal:
           json: 
              library: fastjson
         uri: rest:get:/
   ```
   
   And I got this error in container
   `java.lang.IllegalArgumentException: Unexpected type: class org.apache.camel.model.dataformat.JsonDataFormat`
   
   camel-k 1.8.1, camel
   
   I'm very confused. Why doesn't the "library" usage I found in the unit test of the source code work.
   In addition, I think the yaml file of camel-k also puzzles me when I refer to the java example of camel. I don't know how to convert them accurately.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-k] senayuki closed issue #3212: [SOLVED]Cant specify fastjson when marshal

Posted by GitBox <gi...@apache.org>.
senayuki closed issue #3212: [SOLVED]Cant specify fastjson when marshal
URL: https://github.com/apache/camel-k/issues/3212


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-k] oscerd commented on issue #3212: Cant specify fastjson when marshal

Posted by GitBox <gi...@apache.org>.
oscerd commented on issue #3212:
URL: https://github.com/apache/camel-k/issues/3212#issuecomment-1099999696

   Also Jackson is a thing, Fastjson is another thing.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-k] oscerd commented on issue #3212: Cant specify fastjson when marshal

Posted by GitBox <gi...@apache.org>.
oscerd commented on issue #3212:
URL: https://github.com/apache/camel-k/issues/3212#issuecomment-1099998805

   It should be:
   
   ```
         - marshal:
             json:
               library: Fastjson
   ```
   
   your indentation seems to be wrong


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-k] senayuki commented on issue #3212: Cant specify fastjson when marshal

Posted by GitBox <gi...@apache.org>.
senayuki commented on issue #3212:
URL: https://github.com/apache/camel-k/issues/3212#issuecomment-1100001473

   > Also Jackson is a thing, Fastjson is another thing.
   
   Ow ow ow ow, I did make an indentation mistake. I was stupid! Thanks for your help!
   The Jackson dependency is that I forgot to remove it when I was testing at the beginning, which is not a problem


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-k] oscerd commented on issue #3212: [SOLVED]Cant specify fastjson when marshal

Posted by GitBox <gi...@apache.org>.
oscerd commented on issue #3212:
URL: https://github.com/apache/camel-k/issues/3212#issuecomment-1100051639

   My suggestion is to use jitpack while developing.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-k] oscerd commented on issue #3212: Cant specify fastjson when marshal

Posted by GitBox <gi...@apache.org>.
oscerd commented on issue #3212:
URL: https://github.com/apache/camel-k/issues/3212#issuecomment-1099999312

   It's a different way of writing routes through YAML, so there no automatic conversion, for the moment, from plain camel or Java DSL, to YAML.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-k] senayuki commented on issue #3212: Cant specify fastjson when marshal

Posted by GitBox <gi...@apache.org>.
senayuki commented on issue #3212:
URL: https://github.com/apache/camel-k/issues/3212#issuecomment-1100011139

   > Also Jackson is a thing, Fastjson is another thing.
   
   > Also Jackson is a thing, Fastjson is another thing.
   
   There is another question that puzzles me. I can define a custom serializer module for Jackson in normal Java( just like moduleClassNames, JavaTimeModule  below), but if I use yaml file, do I have any way to use my class without deploy my jar to maven? Just define a class in yaml, and use it, Is this impossible?
   ```
         - marshal:
             json:
               moduleClassNames: "com.fasterxml.jackson.datatype.jsr310.JavaTimeModule"
               disableFeatures: "WRITE_DATES_AS_TIMESTAMPS"
   ```
   The class I want like this
   ```java
   public class TimeSerializer extends SimpleModule {
       public TimeSerializer(){
           super(PackageVersion.VERSION);
           addSerializer(LocalDateTime.class, new LocalDateTimeSerializer());
       }
   }
   ```
   What I want to do is let Jackson serialize LocalDateTime into UNIX timestamp, and Jackson gave me an array, which shocked me, so I'm working with the serializer battle
   
   I'm really confused about the yaml writing method of camel K. instead of seeking automatic conversion, I think the introduction of yaml in camel-k tutorial is too simple and lacks advanced usage
   
   Sorry, my question is beyond the scope of this issues, but this problem really bothers me. If you know, please tell me possible or impossible or don't-know, so I won't try again. Thank you


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org