Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Jul 29, 2026. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 6.4k
JSON_API_cn
wenshao edited this page May 15, 2016
·
7 revisions
JSON这个类是fastjson API的入口,主要的功能都通过这个类提供。
packagecom.alibaba.fastjson;
publicabstractclassJSON {
// 将Java对象序列化为JSON字符串,支持各种各种Java基本类型和JavaBeanpublicstaticStringtoJSONString(Objectobject, SerializerFeature... features);
// 将Java对象序列化为JSON字符串,返回JSON字符串的utf-8 bytespublicstaticbyte[] toJSONBytes(Objectobject, SerializerFeature... features);
// 将Java对象序列化为JSON字符串,写入到Writer中publicstaticvoidwriteJSONString(Writerwriter, Objectobject, SerializerFeature... features);
// 将Java对象序列化为JSON字符串,按UTF-8编码写入到OutputStream中publicstaticfinalintwriteJSONString(OutputStreamos, // Objectobject, // SerializerFeature... features);
}packagecom.alibaba.fastjson;
publicabstractclassJSON {
// 将JSON字符串反序列化为JavaBeanpublicstatic <T> TparseObject(StringjsonStr, Class<T> clazz, Feature... features);
// 将JSON字符串反序列化为JavaBeanpublicstatic <T> TparseObject(byte[] jsonBytes, // UTF-8格式的JSON字符串Class<T> clazz, Feature... features);
// 将JSON字符串反序列化为泛型类型的JavaBeanpublicstatic <T> TparseObject(Stringtext, TypeReference<T> type, Feature... features);
// 将JSON字符串反序列为JSONObjectpublicstaticJSONObjectparseObject(Stringtext);
}importcom.alibaba.fastjson.*;
JSONObjectjsonObj = JSON.parseObject(jsonStr);importcom.alibaba.fastjson.JSON;
Modelmodel = JSON.parseObject(jsonStr, Model.class);importcom.alibaba.fastjson.JSON;
Typetype = newTypeReference<List<Model>>() {}.getType(); List<Model> list = JSON.parseObject(jsonStr, type);importcom.alibaba.fastjson.JSON;
Modelmodel = ...; StringjsonStr = JSON.toJSONString(model);importcom.alibaba.fastjson.JSON;
Modelmodel = ...; byte[] jsonBytes = JSON.toJSONBytes(model);importcom.alibaba.fastjson.JSON;
Modelmodel = ...; OutputStreamos;
JSON.writeJSONString(os, model);importcom.alibaba.fastjson.JSON;
Modelmodel = ...; Writerwriter = ...;
JSON.writeJSONString(writer, model);如有需要修改本注脚,请联系阿里巴巴,
© Alibaba Fastjson Develop Team
注明: 版权所有阿里巴巴,请注明版权所有者
If you need to amend this footnote, please contact Alibaba.
© Alibaba Fastjson Develop Team
Note: Copyright Alibaba, please indicate the copyright owner