4 Replies Latest reply on Apr 28, 2016 11:07 PM by ramandeep

    Replace JSON node name through Camel transformation

    ramandeep

      Hi All,

       

      I have an input Json String which is consumed by rest Binding in Switchyard Project .My Json string is something like one given below

       

        {"idNumber":"539",

        "serviceInstancenumber":175497544,

        "Code":"SERVICE",

        "Ids":[],

        "clientId":"3",

        "service":[]

        }

       

      Now I have a requirement to map the Json node names to some other attribute name e.g idNumber -> InstanceNumber , serviceInstancenumber -> ServiceNumber.

      This mapping has to be done during runtime . So is there any way through which I can achieve this in Switchyard Project  . I have read about Camel transformation but not sure if I can use it . Thanks in advance !!

       

      Regards,

      Ramandeep

        • 1. Re: Replace JSON node name through Camel transformation
          bfitzpat

          Unfortunately this is not currently available in SwitchYard in the 2.0.x version, but we are in the process of implementing changes for the next version (2.1.0) that will support it. You can see that ongoing work in SWITCHYARD-2855. With those changes in place you'll be able to use the Camel Editor and Data Transformation to do exactly what you are looking for.


           

          • 2. Re: Replace JSON node name through Camel transformation
            ramandeep

            Hi All ,

             

             

            I have been trying to do Json2Json dozer transformation in Camel . However I am facing the below error

             

            org.dozer.MappingException: Source object must not be null  
              at org.dozer.util.MappingUtils.throwMappingException(MappingUtils.java:87)  
              at org.dozer.util.MappingValidator.validateMappingRequest(MappingValidator.java:37)  
              at org.dozer.util.MappingValidator.validateMappingRequest(MappingValidator.java:49)  
              at org.dozer.MappingProcessor.map(MappingProcessor.java:103)  
              at org.dozer.MappingProcessor.map(MappingProcessor.java:99)  
              at org.dozer.DozerBeanMapper.map(DozerBeanMapper.java:120)  
              at org.apache.camel.component.dozer.DozerProducer.process(DozerProducer.java:79)  
            

             

            I got a link where someone faced a similar Issue in Json2xml transformation . The link is https://issues.jboss.org/browse/FUSETOOLS-1395.

            However I am not able to get which Jar needs to be included to fix this Issue . I would appreciate any help ,I am quite new to Camel and dozer transformation so awaiting help from the community.

             

             

            Thanks !!

            Ramandeep

            • 3. Re: Replace JSON node name through Camel transformation
              tcunning

              Raman,

               

              Are you seeing this at runtime or in the tooling?    Do you have a small example or steps to reproduce?

              • 4. Re: Replace JSON node name through Camel transformation
                ramandeep

                Hi Tom ,

                 

                The Issue is resolved , after taking the latest dependencies , and creating a new project

                 

                -Ramandeep