2017-10-11 123 views
0

的我有一個包含「學生」對象的ArrayList一個「JudoClass」對象。當我嘗試創建一個學生,我得到上述錯誤。錯誤:com.fasterxml.jackson.databind.JsonMappingException:無法反序列化Entities.Student的情況下進行START_ARRAY令牌

Post方法:

@POST 
@Produces(MediaType.APPLICATION_JSON) 
@Consumes(MediaType.APPLICATION_JSON) 
@Path("/createStudent") 
public Response createAccount(Student aStudent) { 
    students.put(aStudent.getId(), aStudent); 
    allStudents.add(aStudent); 
    System.out.print("user created with id: " + aStudent.getId()); 
    return Response.ok(students, MediaType.APPLICATION_JSON).build(); 
} 

學生是所有學生的哈希映射。 (allStudents是的ArrayList,我既測試)

的Json在郵遞員:

[ 
{ 
    "id": 3, 
    "username": "Mark", 
    "password": "password" 
} 
] 

當我嘗試創建或編輯JudoClass我也得到這個錯誤。

回答

0

你的方法接受一個學生作爲參數

public Response createAccount(Student aStudent) { 

但是你要發送的數組。

那麼你的方法應該看起來像

public Response createAccount(List<Student> aStudent) { 
相關問題