JsonUtils class
- @Author: chuxiong
- @Created at: 18-07-2024 10:45
- @Email:
- description json转化工具类,主要是负责list,map,对象和json之间转化等
Properties
-
hashCode
→ int
-
The hash code for this object.
no setterinherited
-
runtimeType
→ Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
toString()
→ String
-
A string representation of this object.
inherited
Static Methods
-
encodeList(List? list)
→ String?
-
将
List<dynamic> 序列化为 JSON 字符串。null 返回 null;编码失败
记录错误日志并返回 null。
-
encodeObj(dynamic value)
→ String?
-
将任意对象转为 JSON 字符串
-
encodeObject<T>(T? obj, Map<String, dynamic> toJson(T))
→ String?
-
将单个对象转为 JSON 字符串
-
encodeObjectList<T>(List<T>? list, Map<String, dynamic> toJson(T))
→ String?
-
将对象列表转为 JSON 字符串。
-
fromJson<T>(String? jsonStr, T fromMap(Map<String, dynamic> map))
→ T?
-
JSON 字符串转为对象。
-
listFromJson<T>(dynamic source, T fromMap(Map<String, dynamic> map))
→ List<T>?
-
JSON 字符串或列表转为对象列表。
-
logJson(dynamic obj, {bool prettyPrint = true})
→ void
-
以日志方式输出 JSON 字符串(支持缩进)。
-
toMap(String? jsonStr)
→ Map<String, dynamic>?
-
JSON 字符串转为 Map。
-
toMapList(String? jsonStr)
→ List<Map<String, dynamic>>?
-
JSON 字符串转为 List