fastjson是怎么实现JSON的序列化和反序列化的

如题所述

反序列化函数
· parseObject
-将 json字符串 反序列化为 java.class
@sherineZJU
List<T> temp= JSON.parseObject(fastjson,T.class);
//transform the json to T123123

-fastjson 为 json格式的字符串(String类型)
-T 为 与 json格式对应的 自定义 java.class。
· parseObject
-将 json字符串 反序列化为 java.util.List
@sherineZJU
List<T> oldk = JSONArray.parseArray(fastjson,T.class);
//transform the json to List<T>123123

-fastjson 为 json格式的字符串(String类型)
-List< T> 为 与 json格式对应的 自定义 java.util.List。
java.class 与 json字符串 的对应关系
注意 json字符串 的关键字一定要与 java.class 中的对应变量名相同。
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答