Conditional JSON decoder with optional fields

Thanks @wondible

I might be misunderstanding the behaviour of at. With this solution, wouldn’t the decoder returned by decodeRecordTypeDetails operate on the actual name of the type?

So although the types line up, I don’t think this would work because we need to apply that decoder to a field in the original outer JSON.

I tried something which I think was similar and got the following result:

Got bad body (Problem with the value at json[0].type:

    {
        "id": 35,
        "name": "Chair"
    }

Expecting an OBJECT with a field named `type`) when attempting to load JSON!

Have I misunderstood?