0

I would like to create a line chart (android) from data coming from Json (API) but it's a bit difficult. In the following example, I have data from 0 to 4, but if I have thousands of data, how can I do it?

    {
    "0": {
        "strength": 60,
        "angle": 5,
        "date": "2018-07-01T18:45:54.000Z"
    },
    "1": {
        "strength": 33,
        "angle": 52,
        "date": "2018-07-01T18:46:13.000Z"
    },
    "2": {
        "strength": 33,
        "angle": 75,
        "date": "2018-07-01T18:46:21.000Z"
    },
    "3": {
        "strength": 96,
        "angle": 63,
        "date": "2018-07-01T18:46:22.000Z"
    },
    "4": {
        "strength": 30,
        "angle": 40,
        "date": "2018-07-22T02:03:57.000Z"
    },
    "success": true
}
Haytham
  • 35
  • 6
  • **`Its Invalid JSON`** You can check here https://jsonlint.com/ **And better to change your response from back end side** – AskNilesh Jul 23 '18 at 04:08
  • I'm in charge of the application only and not the API. I just edit the JSON and now is valid. – Haytham Jul 23 '18 at 04:10
  • Than ask the person who create that api to change response – AskNilesh Jul 23 '18 at 04:12
  • 1
    I agree with @NileshRathod , Either backend developer should change response and return Array, instead of dynamic objects with keys, or you should use Map as parser topmost object. For LineChart use MPAndroidChart : https://github.com/PhilJay/MPAndroidChart – Misha Akopov Jul 23 '18 at 04:27

0 Answers0