My java pojo looks like this
public class myPersonTO{
String name;
String surname;
Map<String, Double> categories;
}
I am using the gson library, however I an not sure what my json stringn, and the object it is created from should like; I am using json stringify, on a javascript object containing two strings and an array of objects, see pseudo code :
var json = [];
jsonObject = new Object();
jsonObject.name = "testname"
jsonObject.surname = "testsurname"
var categories = [];
for(index=0,index <10;index++){
var category = new Object();
category.key = getKey();
category.value = index;
categories.push(category);
}
jsonObject.categories = categories;
json.push(jsonObject);
json = JSON.stringify(json); //convert json object, then use in submit
and then in Java I am usign the following :
Type listType = new TypeToken<List<myPersonTO>>() {}.getType();
List<myPersonTO> myPersonTOList = new Gson().fromJson(jsonString,listType);
Any help gratefully received. Cheers !