Does anyone know how can I serialize/deserialize a Map<String, dynamic> instead of String that is the default in the toJson
e fromJson
methods of the built_value package?
I need to use Firestore and the setData method only accepts a Map for the data.
My current Serializer class has the code below. There's some other plugin or config that I can add to work with the map?
final Serializers serializers =
(_$serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build();
Here are the methods:
String toJson() {
return json.encode(serializers.serializeWith(Comment.serializer, this));
}
static Comment fromJson(String jsonString) {
return serializers.deserializeWith(
Comment.serializer, json.decode(jsonString));
}