是否有一个库可以将Java POJO转换为JSON和XML? [英] Is there a library to convert Java POJOs to and from JSON and XML?

查看:112
本文介绍了是否有一个库可以将Java POJO转换为JSON和XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个对象图,我想要转换为JSON和XML,以创建REST风格的API。令我感到震惊的是,某人必须已经完成此操作,但使用Google和Stack Overflow进行的快速搜索没有任何结果。

I have an object graph that I would like to convert to and from JSON and XML, for the purposes of creating a REST-style API. It strikes me that someone must have done this already, but a quick search using Google and Stack Overflow reveals nothing.

有没有人知道合适的(Apache或同等的许可证首选)库来做这个吗?

Does anyone know of a suitable (Apache or equivalent license preferred) library to do this?

推荐答案

GSON 来自google: http://code.google.com/p/google-gson/

GSON from google : http://code.google.com/p/google-gson/,

杰克逊春天使用的库: https://github.com/FasterXML/jackson

我会同意其他人建议使用jaxb XML to pojo,支持很多工具:它的标准。

and I would concur with others suggesting jaxb for XML to pojo, well supported lots of tools : its the standard.

这篇关于是否有一个库可以将Java POJO转换为JSON和XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆