We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
toJson
1 parent 69cd117 commit d8c0f17Copy full SHA for d8c0f17
packages/agent_dart_base/lib/candid/idl.dart
@@ -55,7 +55,12 @@ Uint8List? tryToJson(CType type, dynamic value) {
55
// obj may be a map, must be ignore.
56
value is! Map) {
57
try {
58
- return type.encodeValue(value.toJson());
+ try {
59
+ value = value.toIDLSerializable();
60
+ } on NoSuchMethodError {
61
+ value = value.toJson();
62
+ }
63
+ return type.encodeValue(value);
64
} catch (e) {
65
return null;
66
}
@@ -904,7 +909,11 @@ class RecordClass extends ConstructType<Map> {
904
909
bool covariant(dynamic x) {
905
910
if (x is! Map) {
906
911
907
- x = x.toJson();
912
913
+ x = x.toIDLSerializable();
914
915
+ x = x.toJson();
916
908
917
918
return false;
919
0 commit comments