Skip to content

Commit

Permalink
Merge pull request #12 from rundeck-plugins/RUN-2174
Browse files Browse the repository at this point in the history
RUN-2174: add a flag to get the previous quoting behavior parsing json arrays to string
  • Loading branch information
ltamaster authored Feb 1, 2024
2 parents e1456cf + f753b9f commit 9d3bee2
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/main/groovy/com/rundeck/plugins/logging/JsonLogFilter.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ See [here](https://github.com/eiiches/jackson-jq#implementation-status-and-curre
)
Boolean logData

@PluginProperty(
title = 'Extra quotes',
description = '''If true, the result will be parse to string, that will add extra quotes to the result (compatible with rundeck 4.x)''',
defaultValue = 'false'
)
Boolean extraQuotes=false

private StringBuffer buffer;
OutputContext outputContext
Map<String, String> allData
Expand Down Expand Up @@ -115,7 +122,11 @@ See [here](https://github.com/eiiches/jackson-jq#implementation-status-and-curre
if(it.getNodeType()==JsonNodeType.ARRAY){
this.iterateArray(it.elements())
} else if(it.getNodeType()==JsonNodeType.STRING) {
allData.put(prefix, it.asText())
def value = it.asText()
if(extraQuotes){
value = it.toString()
}
allData.put(prefix, value)
} else {
allData.put(prefix, it.toString())
}
Expand All @@ -134,7 +145,11 @@ See [here](https://github.com/eiiches/jackson-jq#implementation-status-and-curre
Integer i=0
list.each{it->
if(it.getNodeType() == JsonNodeType.STRING){
allData.put(prefix +"."+ i.toString(),it.asText())
def value = it.textValue()
if(extraQuotes){
value = it.toString()
}
allData.put(prefix +"."+ i.toString(),value)
}else{
allData.put(prefix +"."+ i.toString(),it.toString())
}
Expand Down Expand Up @@ -162,7 +177,12 @@ See [here](https://github.com/eiiches/jackson-jq#implementation-status-and-curre
}else{
def extractValue
if(value.getNodeType() == JsonNodeType.STRING){
extractValue=value.asText()
if(extraQuotes){
extractValue=value.toString()
}else{
extractValue=value.asText()
}

}else{
extractValue = value.toString()
}
Expand Down

0 comments on commit 9d3bee2

Please sign in to comment.