Closed JustinGrote closed 1 month ago
Have you tried using the YAML 1.2 JSON schema which is meant to be JSON friendly?
@{foo='bar';test=@(1, 2, 'three')} | ConvertTo-Yaml -Schema Yaml12JSON
# {"foo": "bar", "test": [1, 2, "three"]}
No I was not aware that was a thing! Seems to have worked at least for my use case, thanks!
There are a few builtin schemas, I've tried to document them under https://github.com/jborean93/PowerShell-Yayaml/blob/main/docs/en-US/about_YamlEmitting.md#schemas. Let me know if there is anything emitted by that schema that isn't valid JSON and I can look into it further.
To avoid any eccentricities with PowerShell ETS, etc. in converting from YAML to JSON, provide a
-AsJSON
that can serialize theYamlObject
once read into JSON and output as a string.https://dotnetfiddle.net/TntEwC