JSRUN 用代码说话

Api Compare

编辑教程

Api Compare

License & Project URL

License URL
Fastjson Apaceh 2.0 https://github.com/alibaba/fastjson
Gson Apaceh 2.0 https://github.com/google/gson
Jackson Apaceh 2.0 https://github.com/FasterXML/jackson-core

Maven

fastjson

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

fastjson-android

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.1.51.android</version>
</dependency>

jackson

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.7.3</version>
</dependency>

gson

<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.6.2</version>
</dependency>

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<List<Model>>() {}.getType(); 
List<Model> 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);
JSRUN闪电教程系统是国内最先开创的教程维护系统, 所有工程师都可以参与共同维护的闪电教程,让知识的积累变得统一完整、自成体系。 大家可以一起参与进共编,让零散的知识点帮助更多的人。
X
支付宝
9.99
无法付款,请点击这里
金额: 0
备注:
转账时请填写正确的金额和备注信息,到账由人工处理,可能需要较长时间
如有疑问请联系QQ:565830900
正在生成二维码, 此过程可能需要15秒钟