parsing a unstructured JSON timeseries with Argonaut

52 Views Asked by At

a webservice returns unstructured JSON that looks like this:-

{
        "2018-04-09": {
            "1. open": "91.0400",
            "2. high": "93.1700",
            "3. low": "90.6200",
            "4. close": "90.7700",
            "5. volume": "31511758"
        },
        "2018-04-06": {
            "1. open": "91.4900",
            "2. high": "92.4600",
            "3. low": "89.4800",
            "4. close": "90.2300",
            "5. volume": "38026000"
        },
        "2018-04-05": {
            "1. open": "92.4350",
            "2. high": "93.0650",
            "3. low": "91.4000",
            "4. close": "92.3800",
            "5. volume": "29771881"
        }, ...
}

while I can parse the inner part using a Codec as it is regular even if it is ugly, even if I walk the cursor how can I walk down the unbound number of fields that represent the date if I don't know all the Date strings up front?

Is there a way to get all the siblings as JsonOjects and then extract the sibling name and its value?

Is this kind of thing un-parsable with argonaut?

Clues or some example code welcomed. Thanks

1

There are 1 best solutions below

1
Justin Peel On

I would parse it as a Map[String,DailyStats] where DailyStats is the inner part.