mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
read simple values from json
This commit is contained in:
parent
c009e99061
commit
94b69866d2
@ -58,8 +58,19 @@ class InfluxData implements Serializable{
|
|||||||
def value
|
def value
|
||||||
if (name.endsWith(".json")){
|
if (name.endsWith(".json")){
|
||||||
name = name.replace(".json","")
|
name = name.replace(".json","")
|
||||||
script.echo "found JSON content: " + fileContent
|
// net.sf.json.JSONSerializer does only handle lists and maps
|
||||||
value = script.readJSON(text: fileContent)
|
// http://json-lib.sourceforge.net/apidocs/net/sf/json/package-summary.html
|
||||||
|
try{
|
||||||
|
value = script.readJSON(text: fileContent)
|
||||||
|
}catch(net.sf.json.JSONException e){
|
||||||
|
// try to wrap the value in an object and read again
|
||||||
|
if (e.getMessage() == "Invalid JSON String"){
|
||||||
|
def JSONobject = readJSON(text: "{\"content\": ${fileContent}}")
|
||||||
|
value = JSONobject.content
|
||||||
|
}else{
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
// handle boolean values
|
// handle boolean values
|
||||||
if(fileContent == 'true'){
|
if(fileContent == 'true'){
|
||||||
|
Loading…
Reference in New Issue
Block a user