Java中有一種方法可以從json中讀取數據並直接將其值存入Collection中。在我的情況下,我有三種不同的類型。我一定能成功:如何解析Java中的JSON並將值存入Collection
Collection<Type> types;
JSON:
{
"type1":[
{
"version": "1.11",
"releaseDate": "2015-03-26",
"downloadUrl": "****"
},
{
"version": "1.12",
"releaseDate": "2015-04-08",
"downloadUrl": "****"
}],
"type2":[
{
"version": "2.20",
"releaseDate": "2015-03-26",
"downloadUrl": "****"
},
{
"version": "2.21",
"releaseDate": "2015-04-08",
"downloadUrl": "****"
}],
"type3":[
{
"version": "2.56",
"releaseDate": "2015-03-26",
"downloadUrl": "****"
},
{
"version": "2.57",
"releaseDate": "2015-04-08",
"downloadUrl": "****"
}]
}
如何烏爾Type類? – nafas
JSON有很多Java API。其中之一就在這裏:http://www.json.org/java/。 –
也許這應該是一個代表我有3種類型的類,它有一個String版本,realeaseDate和downloadUrl類,但我不知道如何執行此操作。 – alle3x