Skip to content
wenshao edited this page Apr 23, 2016 · 72 revisions

English | [中文] (https://github.com/Alibaba/fastjson/wiki/%E9%A6%96%E9%A1%B5)

Fastjson 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. Fastjson can work with arbitrary Java objects including pre-existing objects that you do not have source-code of.

Fastjson Goals

  • Provide best performance in server side and android client.
  • Provide simple toJSONString() and parseObject() 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)

Frequently Asked Questions

https://github.com/alibaba/fastjson/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98

Download

android developer plz see Here

the latest JAR

or via Maven:

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>VERSION_CODE</version>
</dependency>

or via Gradle:

compile 'com.alibaba:fastjson:VERSION_CODE'

replace VERSION_CODE with real version name such as 1.2.10 released in Here or Here

Getting started

Samples : https://github.com/alibaba/fastjson/wiki/Samples-DataBind

Benchmark

Times are in nanoseconds, sizes are in bytes.

                                 create     ser   +same   deser   +shal   +deep   total   size  +dfl
kryo                                119    1335    1273    1562    1709    1689    3024    223   140
java-manual                         119    2129    2055    1005    1031    1062    3191    255   147
json/fastjson/databind              117    1809    1687    1741    1786    1907    3715    486   262
msgpack                             117    1827    1582    1985    2020    2118    3945    233   146
json/jackson/manual                 118    1672    1501    2235    2232    2365    4037    468   253
protobuf                            227    2939    1362    1626    1661    1965    4904    239   149
thrift                              242    3157    2898    2031    2116    2194    5351    349   197
json/jackson/databind               119    2851    2726    3941    4008    4154    7005    485   261
hessian                             117    6135    5513   10082   10204   10311   16446    501   313
json/google-gson/databind           117   11309   11304    7913    7967    8076   19385    486   259
json/json-lib-databind              119   45547   45114  145951  145866  146582  192129    485   263

Columns:

  • create: create an object (using the classes specified by the serialization tool)
  • ser: create an object and serialize it
  • +same: serialize the same object (i.e. doesn’t include creation time)
  • deser: deserialize an object
  • +shal: deserialize an object and access the top-level fields
  • +deep: deserialize an object and access all the fields
  • total: create + serialize + deserialize and access all fields
  • size: the size of the serialized data
  • +dfl: the size of the serialized data compressed with Java’s built-in implementation of DEFLATE (zlib)

Test code : https://github.com/wenshao/jvm-serializers

Clone this wiki locally