Closed jaysson closed 3 years ago
jsonEncode cannot encode YamlMap but can encode a Map, and hence you can cast it as a Map and then try
jsonEncode(yamlDoc as Map);
That would only work for top level. Any maps inside still throw the same error.
We could consider adding a toJson
, but since Yaml can't be round-tripped through JSON I'm not sure if it is a good idea.
Yaml has a superset of the semantics of json - if you have a YamlMap
with keys of any type other than String
the encoding would fail.
My preference would be to have authors convert to a Map<String, Object?>
manually so they can make the decisions about how to handle Data that cannot be represented as JSON.
throws