-4

I'm trying to parse JSON which is like below:

"price": [
            [
                1539283140000,
                6288.07
            ],
            [
                1539283440000,
                6285.82
            ],
            [
                1539283740000,
                6285.81
            ],
            [
                1539284041000,
                6280.37
            ],
            [
                1539284340000,
                6280.19
            ]

Please help me deal with this. And is there a possibility to decode the timestamp value to a date.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • 3
    You surely tried *something*. Don't hesitate to show your attempt, so that this does not look like a “write the code for me” question! – ielyamani Oct 13 '18 at 18:23
  • And for what it is worth: you are not even showing us valid Json.. – Theo Oct 13 '18 at 18:37

1 Answers1

0

Correct json

{
    "price": [
            [
                1539283140000,
                6288.07
            ],
            [
                1539283440000,
                6285.82
            ],
            [
                1539283740000,
                6285.81
            ],
            [
                1539284041000,
                6280.37
            ],
            [
                1539284340000,
                6280.19
            ]
         ]
}

struct Root: Codable {
    let price: [[Double]]
}

let res = try? JSONDecodable().decode(Root.self,from:jsonData)
Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87