Closed flodaniel closed 3 years ago
Hi, the duo generators make use of BuiltValue. So, what you are interested in is how to generate json from built value.
You can use some thing like this var
contact1 = Contact((b) => b
..id = 1
..fullName = "Stack Secrets");
print(serializers.serialize(contact1));
You can read more about it here https://stacksecrets.com/flutter/json-serialization-in-dart-flutter-with-built_value
Note that you do not need to build your own serialisers as the generated sdk already comes with it.
Thanks! I was looking for that! :)
I am trying to use this package together with the common json_serializable and json_annotation packages (https://pub.dev/packages/json_serializable, https://pub.dev/packages/json_annotation).
However, I am unable to find a way how to the implement a toJSON and fromJSON for the classes generated by openapi-generator-dart. There seems to be an internal implementation, but I cannot access it.
Is there a way to make the packages work together? Otherwise I would have to move away from this package, as I need to store the objects as a JSON. I am using the Generator.dio.
Thanks!