我有一個json
文件,其中保存了特定通道的計劃。現在,我想使用gson將string
轉換爲java對象。我知道這很簡單,但是我對字符串的結構感到困惑。這是我的JSON字符串格式:無法使用GSON將JSON字符串轉換爲JAVA對象
{
"date": "28022014",
"channelName": "star-movies",
"listOfShows": [
{
"showTitle": "Pirates of the Caribbean: The Curse of the Black Pearl",
"showTime": "01:30:00",
"showThumb": "http://tv.burrp.com/images/s/v/v/vv71wogh_644_4_140.jpg",
"showDetails": {
"IMDB Rating": "8.0/10",
"Nominated For": "Bafta Film Award Best Performance by an Actor in 2004: Johnny Depp, Best Sound in 2004: Christopher Boyes; George Watters II, Best in Special Visual Effects: John Knoll; Hal T. Hickel",
"Trivia": "The movie is inspired by, and takes its theme from, the popular Walt Disney theme park ride of the same name.",
"Produced By": "Jerry Bruckheimer",
"Directed By": "Gore Verbinski",
"Show Type:": "Movie",
"Followed By": "Pirates of the Caribbean: Dead Man\u0027s Chest",
"Written By": "Ted Elliott, Terry Rossio",
"Language:": "English",
"Repeats on:": "Sun, Feb 23 11:30PM Tue, Feb 25 7:00AM Wed, Feb 26 2:00PM",
"Music By": "Klaus Badelt",
"Release Date": "9 July 2003",
"Cast": "Johnny Depp, Geoffrey Rush, Orlando Bloom, Keira Knightley, Jack Davenport",
"Genre:": "Action/Adventure Sci-Fi/Fantasy",
"Show Description": "The Governor\u0027s beautiful daughter Elizabeth (Keira Knightley) is kidnapped by the evil Captain Barbossa (Geoffrey Rush). At that point, Will Turner (Orlando Bloom), her would-be suitor, seeks the help of Captain Jack Sparrow (Johnny Depp), a notorious conman. But then, Jack has his own reasons for hunting down Barbossa and his crew. They have stolen Sparrow\u0027s ship, The Black Pearl."
}
},
{
"showTitle": "Fillers",
"showTime": "03:30:00",
"showThumb": "http://tv.burrp.com/images/s/e/i/eims7nmh_1fwv_1_75.jpg",
"showDetails": {
"Repeats on:": "Sat, Feb 22 1:29AM Mon, Feb 24 3:30AM Tue, Feb 25 2:30AM",
"Language:": "English",
"Show Type:": "Promo/Filler",
"Show Description": "It\u0027s a series featuring film based program."
}
},
....
...
}]
}
這是我想出了類結構:
我無法弄清楚如何物化在清單showDetails
?由於它的主要價值對之間有空間......?我在這裏錯過了什麼嗎?或者有沒有解決方法?
目前尚不清楚你的問題是什麼。在Java中建模JSON時遇到問題嗎?或者在嘗試反序列化時遇到一些錯誤?如果你問的是建模,我會建議使用非結構化的Map,因爲它看起來像是可變的鍵值對。 – chrylis
是的,建模是,在這種情況下'maps'如何工作? – faizanjehangir
..並'gson'支持'地圖'? – faizanjehangir