Serialize without key
Hi, i just wanna ask something like, sometime our backend dev return the response like this
[ { "data" : "data1"}, { "data" : "data2"}, { "data" : "data3"} ]
how to handle that with JsonSerializable, a list data without key, thankyou
It could be work well with custom wrapper
class ListWrap {
List<dynamic> list
factory ListWrap.fromJson(List<dynamic> json) => _$ListWrapToJson({"list": json});
List<dynamic> toJson() => _$ListWrapToJson(this)["list"]
}
But will not work with freezed https://github.com/rrousselGit/freezed/issues/451
may consider add a pair option fromJson, toJson to @JsonSerializable
or even just @JsonKey(inline:true)
Are there any updates to this problem?
Can't find any mention in the internet about serializing JSON with root list structure.
or even just
@JsonKey(inline:true)
This looks great for me.