Let's say, I have an Employee class which looks like this:
public class Employee{
Map<String, ArrayList<Salary>> salary = new HashMap<String, ArrayList<Salary>>();
String name;
String age;
}
public class Salary{
String amount;
String currency;
}
What is the smartest way of convertion to/from Json in Java?
Or;
What if my json should look like that:
{
"name": "Test",
"age": "12",
"salary": {
"first": {
"41130": {
"amount": "100",
"currency": "€"
},
"41132": {
"amount": "100",
"currency": "€"
}
},
"second": {
"41129": {
"amount": "100",
"currency": "€"
}
}
}
}
When i tried to convert this to Employee I am getting error below.
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT