License & Project URL

 LicenseURL
FastjsonApaceh 2.0https://github.com/alibaba/fastjson
GsonApaceh 2.0https://github.com/google/gson
JacksonApaceh 2.0https://github.com/FasterXML/jackson-core

Maven

fastjson


    com.alibaba
    fastjson
    1.2.11

fastjson-android


    com.alibaba
    fastjson
    1.1.51.android

jackson


    com.fasterxml.jackson.core
    jackson-databind
    2.7.3

gson


    com.google.code.gson
    gson
    2.6.2

API

Fastjson parse Tree

import com.alibaba.fastjson.*;

JSONObject jsonObj = JSON.parseObject(jsonStr);

Fastjson parse POJO

import com.alibaba.fastjson.JSON;

Model model = JSON.parseObject(jsonStr, Model.class

Fastjson parse POJO Generic

import com.alibaba.fastjson.JSON;

Type type = new TypeReference>() {}.getType(); 
List list = JSON.parseObject(jsonStr, type);

Fastjson convert POJO to json string

import com.alibaba.fastjson.JSON;

Model model = ...; 
String jsonStr = JSON.toJSONString(model);

Fastjson convert POJO to json bytes

import com.alibaba.fastjson.JSON;

Model model = ...; 
byte[] jsonBytes = JSON.toJSONBytes(model)

Fastjson write POJO as json string to OutputStream

import com.alibaba.fastjson.JSON;

Model model = ...; 
OutputStream os;
JSON.writeJSONString(os, model);;

Fastjson write POJO as json string to Writer

import com.alibaba.fastjson.JSON;

Model model = ...; 
Writer writer = ...;
JSON.writeJSONString(writer, model);