camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamalissimo <roman.janu...@gmail.com>
Subject camel-xmljson convert POJO to XML
Date Mon, 13 Jan 2014 09:29:42 GMT
Hello guys, 

I need to cenvert POJO or JSON to XML file. I was sort of able to generate
XML with Jackson library, but I would like to use camel-xmljson and I don't
know how exactly. I read the documentation at
http://camel.apache.org/json.html and I know how to set it up and how to
marshal it, but the main thing I have to do is to set vaiable *enabled* as
an attribute of *username* and I have no idea how.

Here is my POJO TestUser
--------------------------------------------------------------------------------------------------------------------------
TestUser

    public class TestUser extends JsonType
    {
        @JsonProperty("username")
        private final String username;
        @JsonProperty("fullname")
        private final String fullname;
        @JsonProperty("email")
        private final String email;
        @JsonProperty("enabled")
        private final Boolean enabled;
   
        @JsonCreator
        public TestUser(
            @JsonProperty("username") String username, 
            @JsonProperty("fullname") String fullname, 
            @JsonProperty("email") String email,
            @JsonProperty("enabled") Boolean enabled)
            {
                this.username = username;
                this.fullname = fullname;
                this.email = email;
                this.enabled = enabled;
            }
            @JsonGetter("username")
            public String getUsername()
            {
                return username;
            }
            @JsonGetter("fullname")
            public String getFullname()
            {
                return fullname;
            }
            @JsonGetter("email")
            public String getEmail()
            {
                return email;
            }
            @JsonGetter("enabled")
            public Boolean getEnabled()
            {
                return enabled;
            }
        }
    }

and I need to create this XML:

    <TestUser xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="testUser.xsd">
        <product>
            <username enabled="true">FOO</username>
            <fullname>FOO BAR</fullname>
            <mail>foobar@foobar.com</mail>
        </product>
    </TestUser> 

Any help will be appreciated

Thanks
-Roman



--
View this message in context: http://camel.465427.n5.nabble.com/camel-xmljson-convert-POJO-to-XML-tp5745885.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message