Hi! I have a use case where I'm having a YAML file which I need to convert to JSON but with support of
- Joining/Flatten the keys via
.- THis is doable - Adding support of JSON objects as value.
Explaining 2nd case:
Consider this YAML
all:
sticky:
menu:
toast: true
appTheme:
config: []
enable: false
brand:
is_override_enabled: false
x-cache-control: {"max-age": 300,"stale-while-revalidate": 300,"stale-if-error": 300}
common:
network:
error_NET: { "message": "common-v2__network_security_error_message",
"primary_cta": "common-v2__cta_retry",
"secondary_cta": "common-v2__cta_help",
"title": "common-v2__network_security_error_title" }
Here all.appTheme has a YAML based object where it has 2 keys i.e config and enable similarly all.common.network.error_NET also has a value as object but a JSON one. With the help of gopkg.in/yaml.v3" I unmarshall the YAML string but it cant identify the YAML vs JSON objects as value. What I want is, that JSON objects should be directly replaced as value and should not be flattened. Example:
{
// NOTE THIS NOT FLATTENED AS VALUE IS A JSON OBJECT
"all.common.error_NET": { "message": "common-v2__network_security_error_message",
"primary_cta": "common-v2__cta_retry",
"secondary_cta": "common-v2__cta_help",
"title": "common-v2__network_security_error_title" }
// NOTE THAT THIS GOT FLATTENED AS VALUE WAS A YAML OBJECT
"all.appTheme.config": [],
"all.appTheme.enable": false
}
I am unable to achieve this conversion, any ideas?