# 需要导入依赖
1 2 3 4 5 6
| <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.75</version> </dependency>
|
# 实体类转换为 Json
字符串
# Json
字符串转换为实体类
1
| JSON.parseObject(str(json字符串), (实体类).class);
|
# 常见使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| public static final Object parse(String text);
public static final JSONObject parseObject(String text);
public static final <T> T parseObject(String text, Class<T> clazz);
public static final JSONArray parseArray(String text);
public static final <T> List<T> parseArray(String text, Class<T> clazz); public static final String toJSONString(Object object);
public static final String toJSONString(Object object, boolean prettyFormat);
public static final Object toJSON(Object javaObject);
|