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) Map<String, dynamic>?
从文件中读取JSON数据 filePath: 文件路径 返回解析后的Map<String, dynamic>,如果读取失败返回null
writeJsonToFile(Map<String, dynamic> json, String filePath) bool
写入JSON到文件 filePath: 文件路径 json: 要写入的JSON数据