Skip to content

Commit 42b3902

Browse files
committed
Add handling for lists in results
1 parent c08d974 commit 42b3902

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • src/main/java/ch/unibas/dmi/dbis/chronos/agent

src/main/java/ch/unibas/dmi/dbis/chronos/agent/Utils.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,23 @@ of this software and associated documentation files (the "Software"), to deal
2929
import java.io.PrintWriter;
3030
import java.io.UnsupportedEncodingException;
3131
import java.nio.charset.StandardCharsets;
32+
import java.util.List;
3233
import java.util.Map;
3334
import java.util.Properties;
35+
import kong.unirest.json.JSONArray;
3436
import kong.unirest.json.JSONObject;
3537

3638
class Utils {
3739

3840
static void saveResults( final Properties executionResults, final File resultsJsonFile ) throws IllegalStateException {
3941
JSONObject resultsJsonObject = new JSONObject();
4042
for ( Map.Entry<Object, Object> result : executionResults.entrySet() ) {
41-
resultsJsonObject.put( result.getKey().toString(), result.getValue().toString() );
43+
Object obj = result.getValue();
44+
if ( obj instanceof List<?> ) {
45+
resultsJsonObject.put( result.getKey().toString(), new JSONArray( (List<?>) obj ) );
46+
} else {
47+
resultsJsonObject.put( result.getKey().toString(), obj.toString() );
48+
}
4249
}
4350

4451
try ( PrintWriter out = new PrintWriter( resultsJsonFile, StandardCharsets.UTF_8.name() ) ) {

0 commit comments

Comments
 (0)