我有一个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