2013-03-15 199 views
1

我確實收到下面的json數據到我的一個RESTful spring web服務中。我使用spring @RequestBody從請求正文中檢索數據。數據被作爲LinkedHashMap檢索,每個Player和Fixture對象有兩個java.util.ArrayList。但問題是java.util.ArrayList(s)中的每個對象都不是Player或Fixture類型;它又是LinkedHashMap類型。是否有可能告訴Spring將數據轉換成java.util.ArrayList(s)。一個列表應該包含Player的對象,其他應該包含Fixture類型的對象。Spring @RequestBody Json到LinkedHashMap

{"Player":[ 
    {"idPlayer":101,"FirstName":"Stevenson","LastName":"Martin"}, 
    {"idPlayer":102,"FirstName":"Kevin","LastName":"Main"} 
    ], 
"Fixture":[ 
    {"idFixture":1,"HomeTeamId":"2","AwayTeamId":"9"}, 
    {"idFixture":2,"HomeTeamId":"6","AwayTeamId":"2"}, 
    {"idFixture":3,"HomeTeamId":"5","AwayTeamId":"3"} 
    ] 
} 

回答

0

我不認爲這是可能的,如果頂部元素是一個地圖。

但是,如果你可以在地圖切換到另一個類,可以

public class Form { 
    private List<Player> player; 
    private List<Fixture> Fixture; 
    //gettters and setters 
} 
相關問題