How to catch multiple JSON Arrays on a JSON Array with Rest Template?

Asked

Viewed 181 times

0

Hello, I am having collect information from various JSON’s Array within a JSON Array, which follows below, with Rest Template:

{  
   "dataset":{  
      "id":10051093,
      "dataset_code":"SN2017",
      "database_code":"CME",
      "name":"Soybean Futures, July 2017 (SN2017)",
      "description":"Historical CBT futures prices: Soybean Futures, Contract Size: 5,000 bushels (~136 metric tons) Deliverable Grade: #2 Yellow at contract price, #1 Yellow at a 6 cent/bushel premium, #3 Yellow at a 6 cent/bushel discount Tick Size: 1/4 of one cent per bushel ($12.50 per contract) Pricing Unit: Cents per bushel",
      "refreshed_at":"2016-08-06T01:10:52.935Z",
      "newest_available_date":"2016-08-05",
      "oldest_available_date":"2013-11-14",
      "column_names":[  
         "Date",
         "Open",
         "High",
         "Low",
         "Last",
         "Change",
         "Settle",
         "Volume",
         "Open Interest"
      ],
      "frequency":"daily",
      "type":"Time Series",
      "premium":false,
      "limit":null,
      "transform":null,
      "column_index":null,
      "start_date":"2013-11-14",
      "end_date":"2016-08-05",
      "data":[  
         [  
            "2016-08-05",
            955.5,
            972.5,
            954.5,
            966.75,
            14.25,
            967.0,
            4833.0,
            39348.0
         ],
         [  
            "2016-08-04",
            954.5,
            961.5,
            947.25,
            952.0,
            2.5,
            952.75,
            4418.0,
            39858.0
         ],
         [  
            "2016-08-03",
            953.0,
            961.75,
            947.75,
            948.75,
            null,
            950.25,
            6968.0,
            38607.0
         ],
         [  
            "2016-08-02",
            949.5,
            960.5,
            940.25,
            950.5,
            1.75,
            950.25,
            7791.0,
            37459.0
         ],
         [  
            "2016-08-01",
            975.25,
            987.75,
            948.75,
            954.25,
            34.75,
            952.0,
            5553.0,
            37456.0
         ],
         [  
            "2016-07-29",
            966.5,
            987.25,
            956.5,
            984.25,
            23.0,
            986.75,
            4677.0,
            37530.0
         ],
         [  
            "2016-07-28",
            975.75,
            983.25,
            960.5,
            965.0,
            7.25,
            963.75,
            3309.0,
            37460.0
         ],
         [  
            "2016-07-27",
            964.5,
            982.5,
            963.25,
            971.25,
            10.75,
            971.0,
            4951.0,
            36974.0
         ],
         [  
            "2016-07-26",
            950.75,
            967.0,
            949.0,
            960.25,
            9.0,
            960.25,
            3861.0,
            37293.0
         ],
         [  
            "2016-07-25",
            970.25,
            980.5,
            949.25,
            950.0,
            27.0,
            951.25,
            12818.0,
            36501.0
         ],
         [  
            "2016-07-22",
            1000.0,
            1001.75,
            960.5,
            978.75,
            20.5,
            978.25,
            8925.0,
            36133.0
         ],
         [  
            "2016-07-21",
            997.5,
            1013.0,
            994.0,
            1000.0,
            0.5,
            998.75,
            4736.0,
            36061.0
         ],
         [  
            "2016-07-20",
            1011.25,
            1019.5,
            993.75,
            998.0,
            10.5,
            999.25,
            7060.0,
            35072.0
         ],
         [  
            "2016-07-19",
            1040.0,
            1040.0,
            1006.75,
            1012.0,
            32.0,
            1009.75,
            7354.0,
            33820.0
         ],
         [  
            "2016-07-18",
            1020.0,
            1044.75,
            1014.0,
            1041.25,
            10.0,
            1041.75,
            3574.0,
            33898.0
         ],
         [  
            "2016-07-15",
            1038.25,
            1049.0,
            1013.25,
            1031.25,
            5.75,
            1031.75,
            5612.0,
            33971.0
         ],
         [  
            "2016-07-14",
            1065.0,
            1078.0,
            1029.0,
            1038.75,
            27.25,
            1037.5,
            5794.0,
            33386.0
         ],
         [  
            "2016-07-13",
            1058.5,
            1075.0,
            1048.75,
            1062.5,
            11.5,
            1064.75,
            4900.0,
            32862.0
         ],
         [  
            "2016-07-12",
            1026.0,
            1054.0,
            1025.5,
            1051.75,
            26.75,
            1053.25,
            4567.0,
            32688.0
         ],
         [  
            "2016-07-11",
            1040.5,
            1042.5,
            1020.75,
            1027.5,
            0.75,
            1026.5,
            3356.0,
            32230.0
         ],
         [  
            "2016-07-08",
            1004.5,
            1027.75,
            993.25,
            1024.75,
            30.0,
            1027.25,
            4813.0,
            32171.0
         ],
         [  
            "2016-07-07",
            1035.0,
            1041.75,
            996.75,
            997.0,
            32.5,
            997.25,
            7057.0,
            31843.0
         ],
         [  
            "2016-07-06",
            1032.25,
            1034.0,
            1008.0,
            1031.25,
            1.0,
            1029.75,
            7379.0,
            31501.0
         ],
         [  
            "2016-07-05",
            1060.75,
            1062.5,
            1028.5,
            1030.0,
            44.25,
            1030.75,
            5832.0,
            32220.0
         ],
         [  
            "2016-07-01",
            1082.25,
            1088.0,
            1073.5,
            1078.5,
            10.25,
            1075.0,
            3455.0,
            32288.0
         ],
         [  
            "2016-06-30",
            1054.0,
            1096.5,
            1045.75,
            1083.75,
            27.0,
            1085.25,
            13072.0,
            31602.0
         ],
         [  
            "2016-06-29",
            1061.75,
            1068.0,
            1053.75,
            1052.75,
            8.0,
            1058.25,
            2752.0,
            32051.0
         ],
         [  
            "2016-06-28",
            1051.75,
            1075.75,
            1049.0,
            1064.5,
            14.75,
            1066.25,
            3749.0,
            31712.0
         ],
         [  
            "2016-06-27",
            1041.25,
            1056.5,
            1041.25,
            1054.0,
            12.0,
            1051.5,
            2516.0,
            31768.0
         ],
         [  
            "2016-06-24",
            1055.25,
            1063.5,
            1033.5,
            1044.25,
            16.75,
            1039.5,
            3836.0,
            31601.0
         ],
         [  
            "2016-06-23",
            1061.5,
            1068.0,
            1052.25,
            1055.75,
            6.25,
            1056.25,
            2780.0,
            31906.0
         ],
         [  
            "2016-06-22",
            1061.75,
            1070.5,
            1057.5,
            1062.25,
            1.25,
            1062.5,
            2777.0,
            32399.0
         ],
         [  
            "2016-06-21",
            1080.5,
            1084.75,
            1062.5,
            1064.25,
            19.0,
            1063.75,
            2855.0,
            32475.0
         ]
      ]
   }
}

It’s about the property data. Could someone help me how to accomplish this? Thank you.

1 answer

0

Hello,

I don’t know if I understood your doubt, but to perform the mapping of this json, just create something like the following example:

class Request{
    private DataSet dataSet;    
}


class Dataset{
    ...
    private List<List<String>> data;
    ...
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.