yamlToJson function
Implementation
Map<String, Object?>? yamlToJson(String? yamlContent) {
if (yamlContent == null) {
return null;
}
var yamlMap = loadYaml(yamlContent);
if (yamlMap is! Map) {
return null;
}
// A bit paranoid, but I want to make sure this is valid JSON before we got to
// the encode phase.
return sortedJson(json.decode(json.encode(yamlMap))) as Map<String, Object?>;
}