Skip to content

Instantly share code, notes, and snippets.

@polarnik
Created December 14, 2022 14:45
Show Gist options
  • Save polarnik/99bd54cf9108ca9098b2d3ed33887b9c to your computer and use it in GitHub Desktop.
Save polarnik/99bd54cf9108ca9098b2d3ed33887b9c to your computer and use it in GitHub Desktop.
Summary for k6
public class Summary {
public HashMap<String, HashMap<String, Object>> metrics;
public Summary readSummary(String path) throws IOException {
Gson gson = new GsonBuilder().setExclusionStrategies(new MyExclusionStrategy()).create();
try(FileReader f = new FileReader(path)) {
Summary summary = gson.fromJson(f, Summary.class);
return summary;
} catch (IOException e) {throw e;}
}
class MyExclusionStrategy implements ExclusionStrategy {
public boolean shouldSkipField(FieldAttributes f) {
List<String> names = new ArrayList<String>();
names.add("thresholds");
return names.contains(f.getName());
}
@Override public boolean shouldSkipClass(Class<?> aClass) {return false;}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment