bash - Parsing json while executing a curl -
I am requesting the following curl in my bass script to get a coverage report for my build:
codeCoverage = $ (curl -s $ url / job / $ jobname / $ lastbuildNo / cobertura / api / json? Depth = 2)
This is a Jason Reuption Which looks like this:
{"result": {"children": [{"children": [{}}, "element": [{}, {} ], "Name": "com.test.web"}, {"children": [{}}, "element": [{}, {}], "name": "com.test.web.filters" }, "Element": ["name": "class", "ratio": 37.75}, {"name": "conditional", " Ratio ": 11.639 9}, {" name ":" files "" ratio ": 42.70073}, {" name ":" rows "," ratio ": 16.937233}, {" name ":" methods "," ratio " : 23.67 9 6}, {"name": "package", "ratio" 50%> "name": "lines", "ratio": 16.937233
And after removing that value, I can parse the text, but there is no way to get that value
Please use the amazing Jason utility:
jq -r '.results.elements [] | Select (.name == "Rows"). Ratio 'input.json
Comments
Post a Comment