toMap static method
JSON 字符串转为 Map。
⚠️ 精度限制:同 fromJson——大于 2^53 的整数会丢失精度。
Implementation
static Map<String, dynamic>? toMap(String? jsonStr) {
if (jsonStr == null || jsonStr.isEmpty) return null;
try {
final decoded = json.decode(jsonStr);
return decoded is Map<String, dynamic> ? decoded : null;
} catch (e) {
logger.e('JSON 转 Map 失败: $e');
return null;
}
}