3 ms·
>> Here's an example of decoding json with GHC.Generics using typeclasses. >> https://github.com/dmjio/miso/blob/master/examples/xhr/Main.hs#L130-L131 https://
by runeks 9y ago
>> Here's an example of decoding json with GHC.Generics using typeclasses.
>> https://github.com/dmjio/miso/blob/master/examples/xhr/Main.hs#L130-L131 https://github.com/dmjio/miso/blob/master/examples/xhr/Main....
There’s no reason to use genericParseJSON here, you can just write “instance FromJSON APIInfo”. Or leave the instance declaration as it is and safely rename your record fields to e.g. currentUserUrl instead of current_user_url.
The purpose of the camelTo function is to convert “camelCaseExample” into e.g. “camel_case_example” by passing ‘_’ as the first argument. But the APIInfo data structure already uses record fields with underscores in them.