比方說,我有一個Java Person
類:放心 - 泛型列表反序列化
class Person {
String name;
String email;
}
有了放心,你可以反序列化這個JSON對象
{"name":"Bob", "email":"[email protected]"}
使用
一個JavaPerson
實例
Person bob = given().when().get("person/Bob/").as(Person.class);
如何使用REST確保反序列化此JSON陣列y
[{"name":"Bob", "email":"[email protected]"},
{"name":"Alice", "email":"[email protected]"},
{"name":"Jay", "email":"[email protected]"}]
變成List<Person>
?例如,這將方便:
List<Person> persons = given().when().get("person/").as(...);
+1很好地格式化和好問的問題。 – Johan 2013-03-20 18:27:22