I have a bash script that returns something like this:
{
"key1": "value1",
"key2": "value2"
}
I need to get those values saved as a map in groovy. How do I get that returned value stored as a groovy map?
I have a bash script that returns something like this:
{
"key1": "value1",
"key2": "value2"
}
I need to get those values saved as a map in groovy. How do I get that returned value stored as a groovy map?
You'll want to try something like this:
File script = new File('<My_Script_Path>')
def rawJson = script.getText().execute()
def jsonSlurper = new JsonSlurper()
def result = jsonSlurper.parseText(rawJson)
result
should then be structured like your map above.
For more reference, see these links...
You should just need
def out = "script.sh".execute().text
def map = new JsonSlurper().parseText(out)