Please look at the discussions here - Generic decoding of json to an elm record
I had the same question too…