JsonUtil class
JSON工具类 提供一些常用的JSON操作方法
Constructors
- JsonUtil()
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
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
localJsonToModel<
T> (String assetPath, T fromJson(Map< String, dynamic> ), {bool fromSandbox = false}) → Future<T?> - 通用的 JSON 解析为对象的方法。
-
localJsonToModels<
T> (String assetPath, T fromJson(Map< String, dynamic> ), {bool fromSandbox = false}) → Future<List< T> > - 通用的 JSON 数组解析为对象 List 的方法。
-
readJsonFromFile(
String filePath, {bool fromAsset = false}) → Future< Map< String, dynamic> ?> - 从文件中读取 JSON 数据并解析为 Map
-
readModelFromFile<
T> (String filePath, T fromJson(Map< String, dynamic> ), {bool fromAsset = false}) → Future<T?> - 从文件中读取 JSON 并解析为单个对象
-
readModelsFromFile<
T> (String filePath, T fromJson(Map< String, dynamic> ), {bool fromAsset = false}) → Future<List< T> > - 从文件中读取 JSON 数组并解析为对象列表
-
writeJsonToFile(
Map< String, dynamic> json, String filePath) → bool - 写入 JSON 数据到文件
-
writeModelsToFile<
T> (List< T> models, String filePath, Map<String, dynamic> toJson(T)) → bool - 将对象列表写入 JSON 文件
-
writeModelToFile<
T> (T model, String filePath, Map< String, dynamic> toJson(T)) → bool - 将单个对象写入 JSON 文件