-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: dict with number keys #39
Comments
@mulias there's an implied expectation that input is valid JSON (" Otherwise, JSON object fields must be
|
I'm still chewing this over, but here are some initial thoughts I think the best way to think about the scope of this project is that decoders take in values of the type returned by So while it's true that the json spec requires object fields to be strings, when we parse a json encoded object into javascript the resulting JS object can have both string and number keys. So objects with number keys are part of the Maybe relevant, here's how typescript handles string vs number records:
vs
@laurence-bird have you experimented with finding a way to get the behavior you want with the existing decoders? I ask because I'm not 100% sure if it is or is not possible to create a Thanks for the question. I'd look over a PR, but at this point I'm not sure exactly what the API would look like, so I'm not yet confident if this is a feature we can or want to support. |
Currently the dict decoder only supports keys as string types :
json-type-validation/src/decoder.ts
Line 403 in c28d34d
Would you accept a pull request to provide the ability to decode dicts with numbers as keys? Happy to do the work and raise if so
The text was updated successfully, but these errors were encountered: