Sometimes the convention from the server in json doesn't directly map to the styles on the front end. For example, data from the API may be in snake_case when the javascript is using camelCase. Since this library is already parsing and converting raw json to correctly formed typescript compatible types, it seems this would be a great layer to adapt to these differences.
For example, something like the following syntax would be ideal:
const userDecoder: Decoder<User> = object({
firstName: string('first_name'),
lastName: string('last_name'),
username: string()
)};
where the the string decoder has an optional string parameter.
Sometimes the convention from the server in json doesn't directly map to the styles on the front end. For example, data from the API may be in
snake_casewhen the javascript is usingcamelCase. Since this library is already parsing and converting raw json to correctly formed typescript compatible types, it seems this would be a great layer to adapt to these differences.For example, something like the following syntax would be ideal:
where the the string decoder has an optional string parameter.