YARG - pure java collections data loader

To be honest the only reason I’m using the json data loader in YARG is because I don’t see other choice - it’s the easiest solution - using jackson ObjectMapper to convert java collections to json string; still, it’s quite redundant to waste time on the collections-json conversion.

All I have when generating the reports are simple Lists and Maps with calculated values - this is my data. I cannot use the sql loader because of calculated values, and I cannot (?) use the groovy loader, because I don’t know how.

Is it possible to automatically convert the java collections to groovy collection strings? But then - having already java collections, why should it be needed?

You can use jackson for automatically conversation from java objects to map .
Sample for groovy data loader:

import com.fasterxml.jackson.databind.ObjectMapper;

List<A> collections = params['<any param name>'] 
List<Map<String, Object> result = new ArrayList<>()
for (A a : collections) {
    ObjectMapper mapper = new ObjectMapper();
    Map<String, Object> map = mapper.convertValue(obj, Map.class);
return  result

But if you use persistent entities as params, you can use list of entities loader. This loader performs autoconversation.

1 Like