xxf_json
library
Classes
BaseDecoder
BoolConverter
用法一:类上面处理
@JsonSerializable(converters:
StringConverter(),
IntConverter(),
DoubleConverter(),
BoolConverter(),
)
class MyModel {
}
BoolDecoder
bool类型处理中间件
用法: @JsonKey(fromJson:StringDecoder.decodeOrNull)
bool? isAllDay
BoolNullableConverter
用法一:类上面处理
@JsonSerializable(converters:
StringConverter(),
IntConverter(),
DoubleConverter(),
BoolConverter(),
)
class MyModel {
}
BoolStrictConverter
用法一:类上面处理
@JsonSerializable(converters:
StringConverter(),
IntConverter(),
DoubleConverter(),
BoolConverter(),
)
class MyModel {
}
如果类型不匹配,会给出具体内容给日志
DoubleConverter
用法一:类上面处理
@JsonSerializable(converters:
StringConverter(),
IntConverter(),
DoubleConverter(),
BoolConverter(),
)
class MyModel {
}
DoubleDecoder
double 类型处理中间件
用法: @JsonKey(fromJson:DoubleDecoder.decodeOrNull)
double? price;
DoubleNullableConverter
用法一:类上面处理
@JsonSerializable(converters:
StringConverter(),
IntConverter(),
DoubleConverter(),
BoolConverter(),
)
class MyModel {
}
DoubleStrictConverter
用法一:类上面处理
@JsonSerializable(converters:
StringConverter(),
IntConverter(),
DoubleConverter(),
BoolConverter(),
)
class MyModel {
}
如果类型不匹配,会给出具体内容给日志
IntConverter
用法一:类上面处理
@JsonSerializable(converters:
StringConverter(),
IntConverter(),
DoubleConverter(),
BoolConverter(),
)
class MyModel {
}
IntDecoder
int 类型处理中间件
用法: @JsonKey(fromJson:IntDecoder.decodeOrNull)
int? age;
IntNullableConverter
用法一:类上面处理
@JsonSerializable(converters:
StringConverter(),
IntConverter(),
DoubleConverter(),
BoolConverter(),
)
class MyModel {
}
IntStrictConverter
用法一:类上面处理
@JsonSerializable(converters:
StringConverter(),
IntConverter(),
DoubleConverter(),
BoolConverter(),
)
class MyModel {
}
如果类型不匹配,会给出具体内容给日志
JsonConverter <T , S >
Implement this class to provide custom converters for a specific Type .
JsonEnum
Allows configuration of how enum
elements are treated as JSON.
JsonKey
An annotation used to specify how a field is serialized.
JsonLiteral
An annotation used to generate a private field containing the contents of a
JSON file.
JsonSerializable
An annotation used to specify a class to generate code for.
JsonValue
An annotation used to specify how a enum value is serialized.
NumConverter
用法一:类上面处理
@JsonSerializable(converters:
StringConverter(),
IntConverter(),
DoubleConverter(),
BoolConverter(),
)
class MyModel {
}
NumDecoder
num 类型处理中间件
用法: @JsonKey(fromJson:NumDecoder.decodeOrNull)
num? price;
NumNullableConverter
用法一:类上面处理
@JsonSerializable(converters:
StringConverter(),
IntConverter(),
DoubleConverter(),
BoolConverter(),
)
class MyModel {
}
NumStrictConverter
用法一:类上面处理
@JsonSerializable(converters:
StringConverter(),
IntConverter(),
DoubleConverter(),
BoolConverter(),
)
class MyModel {
}
如果类型不匹配,会给出具体内容给日志
StringConverter
用法一:类上面处理
@JsonSerializable(converters:
StringConverter(),
IntConverter(),
DoubleConverter(),
BoolConverter(),
)
class MyModel {
}
StringDecoder
int 类型处理中间件
用法: @JsonKey(fromJson:StringDecoder.decodeOrNull)
String? name;
StringNullableConverter
用法一:类上面处理
@JsonSerializable(converters:
StringConverter(),
IntConverter(),
DoubleConverter(),
BoolConverter(),
)
class MyModel {
}
StringStrictConverter
用法一:类上面处理
@JsonSerializable(converters:
StringConverter(),
IntConverter(),
DoubleConverter(),
BoolConverter(),
)
class MyModel {
}
如果类型不匹配,会给出具体内容给日志
Constants
primitiveConvertors
→ const List <JsonConverter >
基本类型解析器,安全处理,如遇到失败会转换成默认值
primitiveNullableConvertors
→ const List <JsonConverter >
基本类型解析器,安全处理,如遇到失败变成null,适合声明可空类型的字段
primitiveStrictConvertors
→ const List <JsonConverter >
基本类型解析器,不安全处理,用于提示内容,比原错误始信息增加 内容本身到日志里面
解决原始报错,不提示具体内容,不好分析模型的那个字段
Functions
$checkedConvert <T > (Map map , String key , T castFunc (dynamic ), {Object ? readValue (Map , String )? })
→ T
Helper function used in generated code when
JsonSerializableGenerator.checked
is true
.
$checkedCreate <T > (String className , Map map , T constructor (S <S >(String , S (Object ? ), {Object ? readValue (Map , String )? }) ), {Map <String , String > fieldKeyMap = const {} })
→ T
Helper function used in generated code when
JsonSerializableGenerator.checked
is true
.
$checkedNew <T > (String className , Map map , T constructor (), {Map <String , String > ? fieldKeyMap })
→ T
Helper function used in generated code when
JsonSerializableGenerator.checked
is true
.
$checkKeys (Map map , {List <String > ? allowedKeys , List <String > ? requiredKeys , List <String > ? disallowNullValues })
→ void
Helper function used in generated fromJson
code when
JsonSerializable.disallowUnrecognizedKeys
is true for an annotated type or
JsonKey.required
is true
for any annotated fields.
$enumDecode <K extends Enum , V > (Map <K , V > enumValues , Object ? source , {K? unknownValue })
→ K
Returns the key associated with value source
from enumValues
, if one
exists.
$enumDecodeNullable <K extends Enum , V > (Map <K , V > enumValues , Object ? source , {Enum ? unknownValue })
→ K?
Returns the key associated with value source
from enumValues
, if one
exists.
Exceptions / Errors
BadKeyException
A base class for exceptions thrown when decoding JSON.
CheckedFromJsonException
Exception thrown if there is a runtime exception in fromJson
code generated when JsonSerializableGenerator.checked
is true
DisallowedNullValueException
Exception thrown if there are keys with disallowed null
values in a JSON
map that was provided during deserialization.
MissingRequiredKeysException
Exception thrown if there are missing required keys in a JSON map that was
provided during deserialization.
UnrecognizedKeysException
Exception thrown if there are unrecognized keys in a JSON map that was
provided during deserialization.