I had been planning on using simpleXML for my serialization needs, but figured I would try JSON out, to learn something new.
This is the code I am using to try and
You need to give Gson information on the specific generic type of List
you're using (or any generic type you use with it). Particularly when deserializing JSON, it needs that information to be able to determine what type of object it should deserialize each array element to.
Type listOfTestObject = new TypeToken<List<TestObject>>(){}.getType();
String s = gson.toJson(list, listOfTestObject);
List<TestObject> list2 = gson.fromJson(s, listOfTestObject);
This is documented in the Gson user guide.