In shell scripting, I can easily pass any output from a script/command to another script/command with pipe, as they work with lines. eg
cat file.txt | grep "name" | tr "[:lower:]" "[:upper:]"
How do I achieve the same feature with python, that will pass json output from one command to the other command? eg.
cat file.json | json_grep "name" | json_transform "lowercase" "uppercase"
where file.json will contain
{
"name": "john",
"age": "23"
}
the intermediate data that transfer between json_grep and json_transform will become
{
"name": "john",
}
and the final output will become
{
"name": "JOHN",
}
I'm not looking for function to implement the grep or the transform, as I already know how to use the JSON module in Python.
What I'm looking is how to pass the data.
I can use temporary text file, or database to store the intermediate data, but is there any better way than that?