I am able to get the following JSON as an output after running a chef recipe
listener "tcp" {
"tls_disable": 1,
"address": "xx.xxx.xx.xx:8200"
}
However, I want the chef recipe output in the following format:
listener "tcp" {
tls_disable = 1,
address = "xx.xxx.xx.xx:8200"
}
Just use a regular expression. If your JSON response is in a variable called chef_output
, you can use this:
formatted_output = chef_output.gsub(/\"([^\"]+)\":/, '\1 =')