Here is some data that I have:
animal {
dog {
body {
parts {
legs = old
brain = average
tail= curly
}
}
}
cat {
body {
parts {
legs = new
brain = average
tail {
base=hairy
tip=nothairy
}
}
}
}
}
Notice the data is not really json as it has the following rules:
- supports
=or=between key and value pairs. - No
"or,throughout the data. separation of data is based on new line.
Is it even possible to parse this with awk or sed? I tried jq but it does not work as this isn't really true json data.
My goal is to display only "dog" and "cat". Based on them being the top values under "animal".
$ some-magical-command
dog
cat
dogandcatis quite simple; you could even do it in bash. But is that really the limit of your requirements? In case it is, I'll add an answer.