Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving the capture of nested data from set_stats #395

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import java.util.regex.PatternSyntaxException
import java.util.Iterator
import com.google.gson.JsonParser
import com.google.gson.JsonObject
import com.google.gson.JsonElement
import com.google.gson.GsonBuilder
import com.google.gson.Gson


/**
Expand Down Expand Up @@ -68,9 +69,10 @@ class AnsibleSetStatsFilterPlugin implements LogFilterPlugin{
String jsonString = match.group(1)
JsonObject obj = JsonParser.parseString(jsonString).getAsJsonObject()
Iterator<String> keys = obj.keySet().iterator()
Gson gson = new GsonBuilder().create()
while(keys.hasNext()) {
String key = keys.next()
String value = obj.get(key).getAsString()
String value = gson.toJson(obj.get(key))
allData[key] = value
outputContext.addOutput("data", key, value)
}
Expand Down