google ——gson

来源:互联网 发布:最离奇的杀人案件知乎 编辑:程序博客网 时间:2024/06/07 00:12

官方网站:

http://code.google.com/p/google-gson/

Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object. Gson can work with arbitrary Java objects including pre-existing objects that you do not have source-code of.

There are a few open-source projects that can convert Java objects to JSON. However, most of them require that you place Java annotations in your classes; something that you can not do if you do not have access to the source-code. Most also do not fully support the use of Java Generics. Gson considers both of these as very important design goals.

Gson Goals

  • Provide simple toJson() and fromJson() methods to convert Java objects to JSON and vice-versa
  • Allow pre-existing unmodifiable objects to be converted to and from JSON
  • Extensive support of Java Generics
  • Allow custom representations for objects
  • Support arbitrarily complex objects (with deep inheritance hierarchies and extensive use of generic types)

Gson Documentation

  • Gson API: Javadocs for the current Gson release
  • Gson user guide: This guide contains examples on how to use Gson in your code.
  • Gson Roadmap: Details on upcoming releases
  • Gson design document: This document discusses issues we faced while designing Gson. It also include a comparison of Gson with other Java libraries that can be used for Json conversion

Please use the google-gson Google Group to discuss Gson, or to post questions

 

翻译:

         Gson 是一个java库,用来将java对象转换为JSON表现。 Gson也被用来将一个json 字符串转换为java对象。Gson可以作用与任意java对象,包括以前存在的,没有源代码的对象。

         有一些开源项目能够将java对象转换为json。然而,用gson大多数的时候要再你的类里面加入注解;如果你没有看过源代码有些程序你不能做(不知道)。多数也不完全支持泛型的

使用。Gson认为这些是非常重要的设计目标。

 

Gson 文档:

  • Gson API: Javadocs for the current Gson release
  • Gson user guide: 有例子指导如何使用Gson
  • Gson Roadmap:  最新发布版本的详情
  • Gson design document: 该文档主要说了一些设计gson时候遇到的问题,也包含了对比gson和其他用于json的java库
  • This document discusses issues we faced while designing Gson. It also include a comparison of Gson with other Java libraries that can be used for Json conversion