这是格式化的json:
{
"build":42606,
"torrents":[
[
"084D1BDC1FDF82264A3554E59B64BAA3579D5F0E",
136,
"Terminator.Genisys.2015.SLOSubs.BRRip.XviD-DrSi",
2822006528,
1000,
2822006528,
26460160,
9,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"a20a7306",
1459594469,
1459605260,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Terminator.Genisys.2015.SLOSubs.BRRip.XviD-DrSi",
0,
"4F292253"
],
[
"12B3CD13C55736D3628FFAF03729F20AF9C4F8B8",
136,
"Deadwood.S01.S02.S03.Complete.720p.X264.anoXmous",
15842766215,
1000,
15851187591,
495731725,
31,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"73df595a",
1465650191,
1476891125,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Deadwood.S01.S02.S03.Complete.720p.X264.anoXmous",
0,
"835CC3D4"
],
[
"1ED3FC20FB7B124B8517FDB45A419819322EB430",
136,
"Captain.America.Civil.War.2016.SLOSubs.BRRip.XviD-DrSi",
3431757620,
1000,
3431790388,
1146880,
0,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"54da6a47",
1474567765,
1475745737,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Captain.America.Civil.War.2016.SLOSubs.BRRip.XviD-DrSi",
0,
"0258A882"
],
[
"205A8A81E5B72F109005710B8EBE868FF99D47AD",
136,
"Black.Mirror.2011.S01.SLOSubs.DVDRip.XviD-SCC",
1308362787,
1000,
1308362787,
11862016,
9,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"32e25ce4",
1475870101,
1476030010,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Black.Mirror.2011.S01.SLOSubs.DVDRip.XviD-SCC",
0,
"B471014B"
],
[
"266B8FF68B56DAB45948422472F6889BC4600BCB",
136,
"Hardcore.Henry.2015.SLOSubs.DVDRip.XviD-DrSi",
1504050669,
1000,
1504050669,
3358720,
2,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"54da6a43",
1474567616,
1474573185,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Hardcore.Henry.2015.SLOSubs.DVDRip.XviD-DrSi",
0,
"E0923AE7"
],
[
"27C1E716F202ADE4602531340BEC6E3B56FF48F6",
136,
"The.Lobster.2015.SLOSubs.BRRip.XviD-DrSi",
2474087019,
1000,
2474087019,
1720320,
0,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"a20a730b",
1459594461,
1459604065,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\The.Lobster.2015.SLOSubs.BRRip.XviD-DrSi",
0,
"C12365B2"
],
[
"2C8988AC16E890C479E66A10DAEA7EFE80CA9BD5",
136,
"The.Nice.Guys.2016.SLOSubs.720p.BRRip.XviD-DrSi",
3979341483,
1000,
3979538091,
5668864,
1,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"54da6a49",
1474568017,
1476007444,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\The.Nice.Guys.2016.SLOSubs.720p.BRRip.XviD-DrSi",
0,
"6FA36915"
],
[
"2D583F86019AF1C3255318434795E401D28C2A42",
136,
"The 100 - Season 1 Complete - ChameE",
1764398491,
1000,
1797952923,
752216886,
418,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"92b6df0d",
1465643724,
1465658168,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\The 100 - Season 1 Complete - ChameE",
0,
"57F40AB4"
],
[
"2DBE408C575246FA5BDE7A7C08B58D4CF334BF2A",
136,
"The.Elder.Scrolls.V.Skyrim.Legendary.Edition-WaLMaRT",
14012789923,
723,
10138907811,
13615104,
1,
0,
0,
0,
"",
0,
0,
0,
0,
47270,
1,
3873914880,
"",
"",
"Stopped 72.3 %",
"fc996e5d",
1475151155,
0,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\The.Elder.Scrolls.V.Skyrim.Legendary.Edition-WaLMaRT",
0,
"1908DDF3"
],
[
"4378666D8A6BCFBE1640629C0EFC05691930919B",
136,
"Legend.2015.SLOSubs.BRRip.XviD-DrSi",
2912295322,
1000,
0,
2277376,
0,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"a20a7308",
1459594469,
1459594741,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Legend.2015.SLOSubs.BRRip.XviD-DrSi",
0,
"1B32519E"
],
[
"440B0AC8BAADF9394900B431A59C3A237FDCFE5B",
136,
"TWENTY ONE PILOTS - DISCOGRAPHY (2009-15)",
741321898,
1000,
742370474,
9355264,
12,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"234c1a19",
1475605160,
1476021216,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\TWENTY ONE PILOTS - DISCOGRAPHY (2009-15)",
0,
"A50394AA"
],
[
"44E4BE427506FBFB5BF1958B0D536B23431EEC42",
136,
"The Do Over 2016 720p WEBRip x264.mp4",
1602822762,
1000,
1602822762,
888586240,
554,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"d934c8d9",
1465229127,
1465473660,
"",
"C:\\Users\\davidvuckovic7\\Downloads",
0,
"C114EE01"
],
[
"4D8A586D25273083630D448A7B2802A3F6B4B3FF",
136,
"The.Witcher.3_Wild.Hunt-Game.of.the.Year.Edition-Black.Box",
27715377657,
55,
1528987648,
144916480,
94,
0,
0,
0,
"",
0,
0,
0,
0,
3451,
2,
26186390009,
"",
"",
"Stopped 5.5 %",
"7f716c8",
1476012913,
0,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\The.Witcher.3_Wild.Hunt-Game.of.the.Year.Edition-Black.Box",
0,
"FDABDBB3"
],
[
"5563D6A4C5C8F67AFBB92832396942CBAE18AAA5",
136,
"Everybody.Wants.Some!!.2016.SLOSubs.BRRip.XviD-DrSi",
2582164468,
1000,
2582164468,
34193408,
13,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"54da6a42",
1474567564,
1475160531,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Everybody.Wants.Some!!.2016.SLOSubs.BRRip.XviD-DrSi",
0,
"F4A9360F"
],
[
"63626016DB43514A96AC09FCB3262B9E6699E551",
136,
"Narcos.Complete.Season.2.2016.CROSubs.720p.WEBRip.XviD-HDVid",
14710347522,
1000,
14735595266,
604585984,
41,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"54da6a41",
1474566493,
1476032719,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Narcos.Complete.Season.2.2016.CROSubs.720p.WEBRip.XviD-HDVid",
0,
"9B268512"
],
[
"6396C5D5FC9A8FA232FA278482847248AD19975C",
136,
"Warcraft.2016.SLOSubs.BRRip.XviD-DrSi",
2701287242,
1000,
2701287242,
72605514,
26,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"54da6a3f",
1474566440,
1475159248,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Warcraft.2016.SLOSubs.BRRip.XviD-DrSi",
0,
"EBCBFD16"
],
[
"8C962835C0762AC651C40009325F1CA82C497A4E",
136,
"The.Dark.Knight.2008.SLOSubs.DVDRip.XviD-DrSi",
1473314116,
1000,
1473330500,
69992448,
47,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"8af5d85f",
1474639073,
1475773687,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\The.Dark.Knight.2008.SLOSubs.DVDRip.XviD-DrSi",
0,
"65C4DB54"
],
[
"993CD9F34B194A4B05F87C451857F9A84205F391",
136,
"12 Monkeys S01 Season 01 Complete 480p HDTV x264 AAC E-Subs [GWC]",
1992113106,
1000,
1992113106,
1831287762,
919,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"1d",
1465990457,
1465999660,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\12 Monkeys S01 Season 01 Complete 480p HDTV x264 AAC E-Subs [GWC]",
0,
"4D711958"
],
[
"A40CF513587DCB4E357F32D4EEF5FA22FC00B419",
136,
"Age.of.Empires.II.HD.The.African.Kingdoms-CODEX",
2261948011,
1000,
2261948011,
19972096,
8,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"f0ea6d39",
1471178190,
1471251153,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Age.of.Empires.II.HD.The.African.Kingdoms-CODEX",
0,
"22B115FA"
],
[
"B1949C19DEA6BE31B324EC9BDD2A02DE6DA68DAF",
136,
"Age of Empires II + The Conquerors Expansion",
535058945,
1000,
535058945,
114688,
0,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"f0ea6d38",
1471178191,
1471181744,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Age of Empires II + The Conquerors Expansion",
0,
"2A7DD632"
],
[
"B5B3F96DF541F3C7600715C12C2D0A216885383C",
136,
"Solace.2015.SLOSubs.BRRip.XviD-DrSi",
2264273769,
1000,
2264273769,
11960320,
5,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"a20a7309",
1459594468,
1459603265,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Solace.2015.SLOSubs.BRRip.XviD-DrSi",
0,
"E7504915"
],
[
"BADE5A7A9D591BCDB5DC59B39A64232E3B631B60",
136,
"Zoolander.2.2016.HDRip.XViD-ETRG",
741144534,
1000,
741144534,
72269824,
97,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"af8512e1",
1463823614,
1463826028,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Zoolander.2.2016.HDRip.XViD-ETRG",
0,
"3DCD447A"
],
[
"C9FAFA76E6FCE31E66828CB1419ABDAF803B5035",
136,
"Stronghold Crusader.rar",
443822383,
1000,
443822383,
5570560,
12,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"f0ea6d3d",
1471179809,
1471181567,
"",
"C:\\Users\\davidvuckovic7\\Downloads",
0,
"CB31D401"
],
[
"CE8357DED670F06329F6028D2F2CEA6F514646E0",
136,
"Zootopia 2016 1080p HDRip x264 AC3-JYK",
2926361304,
1000,
2934749912,
235499728,
80,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"af8512de",
1463823431,
1465234867,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Zootopia 2016 1080p HDRip x264 AC3-JYK",
0,
"4469DAF6"
],
[
"D07B0DAB16BF8157B814DF27074CE715E11F27EA",
136,
"Westworld.S01E01.SLOSubs.720p.HDTV.x264-FLEET",
1332100569,
1000,
1332100569,
671744,
0,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"256b6ca0",
1475662529,
1476027460,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Westworld.S01E01.SLOSubs.720p.HDTV.x264-FLEET",
0,
"F825F212"
],
[
"DE45A69835A597868DEF2E2FEF087D7B8DF61DD9",
136,
"Momentum.2015.SLOSubs.BRRip.XviD-DrSi",
2150385510,
1000,
2150385510,
7815168,
3,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"a20a7307",
1459594469,
1459603607,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Momentum.2015.SLOSubs.BRRip.XviD-DrSi",
0,
"E011F7F1"
],
[
"EBE369A5762FE1E233E56BE90CA5D707F29B3D86",
136,
"Atlanta.S01E07.XviD-AFG",
331629452,
1000,
331629452,
0,
0,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"575a24fa",
1476528591,
1476529013,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Atlanta.S01E07.XviD-AFG",
0,
"D828E9B8"
],
[
"EFF0C3EFD9C86646B337FE61CD637CCE59D4FD8E",
201,
"Anthropoid.2016.LiMiTED.SLOSubs.BRRip.XviD-DrSi",
2686178277,
1000,
2686178277,
1074320357,
399,
51085,
176,
-1,
"",
4,
57,
0,
5,
129997,
-1,
0,
"",
"",
"Seeding 100.0 %",
"2ab44b9d",
1478857910,
1478860313,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\Anthropoid.2016.LiMiTED.SLOSubs.BRRip.XviD-DrSi",
0,
"4DE9F939"
],
[
"F57D4098BC49996D12F0D89858A1284E1FE1DDC7",
136,
"London.Has.Fallen.2016.1080p.BluRay.6CH.ShAaNiG.mkv",
1867896803,
1000,
1867913187,
436268998,
233,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"d934c8da",
1465229126,
1465473428,
"",
"C:\\Users\\davidvuckovic7\\Downloads",
0,
"ECD71F0C"
],
[
"FDE79363FE8D0942ED745632100B313076C744C2",
136,
"The.Boss.2016.THEATRiCAL.SLOSubs.BRRip.XviD-DrSi",
2164785053,
1000,
2164785053,
573440,
0,
0,
0,
0,
"",
0,
0,
0,
0,
65536,
-1,
0,
"",
"",
"Finished 100.0 %",
"54da6a48",
1474568002,
1475745965,
"",
"C:\\Users\\davidvuckovic7\\Downloads\\The.Boss.2016.THEATRiCAL.SLOSubs.BRRip.XviD-DrSi",
0,
"61DE02AC"
]
],
"label":[
],
"torrentc":"749574273",
"rssfeeds":[
],
"rssfilters":[
]
}
这是json的味道。正如你所看到的,在种子json数组中只有一堆值。但是,我知道每个值的含义是什么,它们总是在同一个位置。
我无法使用
jsonArray.getString("something") because there are no tags.
我会把它放在哪里而不是这个?让我们说我想得到
" 084D1BDC1FDF82264A3554E59B64BAA3579D5F0E"这个值超出了数组的第一个索引,我怎么能得到它?我知道我的问题到处都是,随时可以提出进一步的问题。
答案 0 :(得分:0)
Json格式应该是Key-Value对。这个json响应似乎无效 你仍然可以尝试这个来解析它
JSONOArray jsonArray = jsonObject.getJSONArray("torrents");
for(int i = 0;i < jsonArray.length();i++){
JSONArray newArray = jsonArray.get(i);
for(int j = 0;j < newArray.length();j++){
//get All the values from the individual array
String x = newArray.get(j);
}
}eate its object
现在存储数组值
创建一个带有相关字段名称的pojo,并在Inner for循环中创建其对象并设置值。
答案 1 :(得分:0)
正如你所看到的,在种子json数组中只有一堆值。
不,torrents
数组中有一堆数组。每个那些数组都包含一系列值。
我会把它放在哪里呢?
假设jsonArray
为a JSONArray
,您可以在内部数组上调用getString(0)
,getInt(1)
等。
答案 2 :(得分:0)
首先:json看起来很糟糕!
尝试使用此结构:
{
build : 123,
torrents : [
{
id : 084D1BDC1FDF82264A3554E59B64BAA3579D5F0E
name : Terminator.Genisys.2015.SLOSubs.BRRip.XviD-DrSi
path : C:\\Users\\davidvuckovic7\\Downloads\\Hardcore.Henry.2015.SLOSubs.DVDRip.XviD-DrSi
},
{
id : 084D1BDC1FDF82264A3554E59B64BAA3579D5F0E
name : Terminator.Genisys.2015.SLOSubs.BRRip.XviD-DrSi
path : C:\\Users\\davidvuckovic7\\Downloads\\Hardcore.Henry.2015.SLOSubs.DVDRip.XviD-DrSi
}
]
}
你知道吗,我是什么意思?你的torrents-array包含很多数组。第二个数组中的数据始终相同。为此,您可以使用对象而不是数组!不需要再次使用数组了!
要获取数据,您可以使用以下内容:
JSONObject obj = new JSONObject(result);
String build : obj.getJSONObject("build");
JSONArray torrents = obj.getJSONArray("torrents");
现在你可以简单地遍历数组:
for(int i = 0; i < torrents .length(); i++) {
JSONObject torrent = torrents.getJSONObject(i);
String name = torrent.getString("name");
...
}