java如何用json解析数组?


{"asks":[[3949,136.857],[3948.88,0.083],[3948.42,0.01],[3948,16.251],[3947.27,0.126],[3947,0.418],[3946.03,1.219],[3945.59,0.01],[3945,0.01],[3944,0.01],[3943.04,3.393],[3942.67,0.01],[3940,41.151],[3939.99,5],[3939.7,1],[3939,1],[3938.59,0.01],[3938,1.81],[3936.5,0.1],[3934.64,0.1],[3934.56,0.1],[3934,0.05],[3933.27,0.5],[3933,0.2],[3932.83,28],[3932,0.01],[3931,0.697],[3930,43.02],[3929.99,5],[3929.2,0.841],[3929,24.41],[3928.02,2],[3927,15.645],[3926.37,6],[3926.02,0.689],[3926,0.51],[3925.5,25.753],[3925,0.63],[3924.88,0.24],[3924.83,0.01],[3924.8,9.478],[3923,0.2],[3922.99,0.3],[3922,0.5],[3921,0.01],[3920.99,0.3],[3920.05,0.2],[3920,0.01],[3919.9,3.701],[3919.89,0.71],[3919,0.01],[3918.99,0.831],[3918.27,0.07],[3918,0.01],[3917,0.34],[3916.99,0.3],[3916,0.01],[3915,30.01],[3914.98,1.894],[3914.96,0.052]],"bids":[[3914.07,0.24],[3914.05,1.62],[3914.02,1.269],[3914,3.747],[3913,0.01],[3912.54,0.018],[3912,0.01],[3911.49,2.627],[3911,0.01],[3910.1,0.04],[3910,0.01],[3909,0.67],[3908,0.01],[3907,1.01],[3906.1,5],[3906.01,0.3],[3906,0.01],[3905,8.21],[3904.01,0.3],[3904,0.01],[3903,0.01],[3902.01,0.3],[3902,0.01],[3901,1.29],[3900.5,0.7],[3900.15,0.78],[3900.14,0.01],[3900.01,0.3],[3900,5.93],[3899.86,0.03],[3899,0.01],[3898.01,0.3],[3898,0.01],[3897.63,6],[3897,0.01],[3896.5,3.251],[3896.01,0.3],[3896,0.01],[3895,0.01],[3894.14,0.01],[3894.01,0.3],[3894,0.01],[3893,0.01],[3892.01,0.3],[3892,0.01],[3891.03,0.01],[3891,0.01],[3890.37,1.058],[3890.01,0.3],[3890,4.182],[3889,1.45],[3888.01,0.3],[3888,1.81],[3887.91,0.01],[3887,0.01],[3886.01,0.3],[3886,0.01],[3885,5.61],[3884.4,0.01],[3884.01,0.3]]}

这样一串如何解析?里面[3886.01,0.3] 这样一个左边代表价格(3886.01),右边代表数量(0.3) 如何解析?

json java 数组

三日月D豬頭 10 years, 7 months ago

先格式化。 http://jsonlint.com/
然后按照数组一个一个解析。。


 {
"asks": [
    [
        3949,
        136.857
    ],
    [
        3948.88,
        0.083
    ],
    [
        3948.42,
        0.01
    ],
    [
        3948,
        16.251
    ],
    [
        3947.27,
        0.126
    ],
    [
        3947,
        0.418
    ],
    [
        3946.03,
        1.219
    ],
    [
        3945.59,
        0.01
    ],
    [
        3945,
        0.01
    ],
    [
        3944,
        0.01
    ],
    [
        3943.04,
        3.393
    ],
    [
        3942.67,
        0.01
    ],
    [
        3940,
        41.151
    ],
    [
        3939.99,
        5
    ],
    [
        3939.7,
        1
    ],
    [
        3939,
        1
    ],
    [
        3938.59,
        0.01
    ],
    [
        3938,
        1.81
    ],
    [
        3936.5,
        0.1
    ],
    [
        3934.64,
        0.1
    ],
    [
        3934.56,
        0.1
    ],
    [
        3934,
        0.05
    ],
    [
        3933.27,
        0.5
    ],
    [
        3933,
        0.2
    ],
    [
        3932.83,
        28
    ],
    [
        3932,
        0.01
    ],
    [
        3931,
        0.697
    ],
    [
        3930,
        43.02
    ],
    [
        3929.99,
        5
    ],
    [
        3929.2,
        0.841
    ],
    [
        3929,
        24.41
    ],
    [
        3928.02,
        2
    ],
    [
        3927,
        15.645
    ],
    [
        3926.37,
        6
    ],
    [
        3926.02,
        0.689
    ],
    [
        3926,
        0.51
    ],
    [
        3925.5,
        25.753
    ],
    [
        3925,
        0.63
    ],
    [
        3924.88,
        0.24
    ],
    [
        3924.83,
        0.01
    ],
    [
        3924.8,
        9.478
    ],
    [
        3923,
        0.2
    ],
    [
        3922.99,
        0.3
    ],
    [
        3922,
        0.5
    ],
    [
        3921,
        0.01
    ],
    [
        3920.99,
        0.3
    ],
    [
        3920.05,
        0.2
    ],
    [
        3920,
        0.01
    ],
    [
        3919.9,
        3.701
    ],
    [
        3919.89,
        0.71
    ],
    [
        3919,
        0.01
    ],
    [
        3918.99,
        0.831
    ],
    [
        3918.27,
        0.07
    ],
    [
        3918,
        0.01
    ],
    [
        3917,
        0.34
    ],
    [
        3916.99,
        0.3
    ],
    [
        3916,
        0.01
    ],
    [
        3915,
        30.01
    ],
    [
        3914.98,
        1.894
    ],
    [
        3914.96,
        0.052
    ]
],
"bids": [
    [
        3914.07,
        0.24
    ],
    [
        3914.05,
        1.62
    ],
    [
        3914.02,
        1.269
    ],
    [
        3914,
        3.747
    ],
    [
        3913,
        0.01
    ],
    [
        3912.54,
        0.018
    ],
    [
        3912,
        0.01
    ],
    [
        3911.49,
        2.627
    ],
    [
        3911,
        0.01
    ],
    [
        3910.1,
        0.04
    ],
    [
        3910,
        0.01
    ],
    [
        3909,
        0.67
    ],
    [
        3908,
        0.01
    ],
    [
        3907,
        1.01
    ],
    [
        3906.1,
        5
    ],
    [
        3906.01,
        0.3
    ],
    [
        3906,
        0.01
    ],
    [
        3905,
        8.21
    ],
    [
        3904.01,
        0.3
    ],
    [
        3904,
        0.01
    ],
    [
        3903,
        0.01
    ],
    [
        3902.01,
        0.3
    ],
    [
        3902,
        0.01
    ],
    [
        3901,
        1.29
    ],
    [
        3900.5,
        0.7
    ],
    [
        3900.15,
        0.78
    ],
    [
        3900.14,
        0.01
    ],
    [
        3900.01,
        0.3
    ],
    [
        3900,
        5.93
    ],
    [
        3899.86,
        0.03
    ],
    [
        3899,
        0.01
    ],
    [
        3898.01,
        0.3
    ],
    [
        3898,
        0.01
    ],
    [
        3897.63,
        6
    ],
    [
        3897,
        0.01
    ],
    [
        3896.5,
        3.251
    ],
    [
        3896.01,
        0.3
    ],
    [
        3896,
        0.01
    ],
    [
        3895,
        0.01
    ],
    [
        3894.14,
        0.01
    ],
    [
        3894.01,
        0.3
    ],
    [
        3894,
        0.01
    ],
    [
        3893,
        0.01
    ],
    [
        3892.01,
        0.3
    ],
    [
        3892,
        0.01
    ],
    [
        3891.03,
        0.01
    ],
    [
        3891,
        0.01
    ],
    [
        3890.37,
        1.058
    ],
    [
        3890.01,
        0.3
    ],
    [
        3890,
        4.182
    ],
    [
        3889,
        1.45
    ],
    [
        3888.01,
        0.3
    ],
    [
        3888,
        1.81
    ],
    [
        3887.91,
        0.01
    ],
    [
        3887,
        0.01
    ],
    [
        3886.01,
        0.3
    ],
    [
        3886,
        0.01
    ],
    [
        3885,
        5.61
    ],
    [
        3884.4,
        0.01
    ],
    [
        3884.01,
        0.3
    ]
 ]
}

小珊俺D嫁 answered 10 years, 7 months ago

Your Answer