Ilkar
Ilkar

Reputation: 2167

Spring JSON and XML

I'm building an application based on Spring 3 and i'm wondering, is there any Spring library for creating JSON ans XML object?

Let say, that i want to create and XML or JSON with a variable and send it to webservice.

I was looking in google, but i dodn't found anything special.

Coult you help me?

Upvotes: 0

Views: 1059

Answers (2)

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340708

For creating XML objects you should use JAXB and spring-oxm project. They simplify XML handling significantly.

For JSON, Jackson library is used most commonly.

Note that if you want to consume or product XML/JSON from Spring MVC, just expect/return Java objects in your controllers. Spring will do the marshalling and unmarshalling for you. XML is for free, JSON support will be enabled automatically if Jackson is available.

Finally if you want to be a client of SOAP web service, try spring-ws. If this is a REST service, RestTemplate was designed especially for you.

Upvotes: 1

NimChimpsky
NimChimpsky

Reputation: 47280

Spring uses jackson to convert pojo's to json, automatically for you.

To marshall data from xml to pojos you could use jaxb (not part of spring).

Upvotes: 0

Related Questions