I have big complex YAML file, which I successfully read into serde_yaml::Value
and need to send to the user (from Axum handler) as JSON.
But somewhere deep inside that big YAML there are keys like null
. And serde_json::json!
panics with message "key must be a string".
I understand that this is valid case for YAML, but not valid for JSON.
But is there some workaround for that? I just need string keys like "null"
in place of those nulls.
JavaScript and Go YAML parsers behaves exactly like this...
I wrote a big recursive function for that, which manually converts values, but maybe this is overkill. And also my function somehow breaks YAML merges (<<
), don't know why yet.