json decode silently discards quoted numeric types #23424
Labels
Bug
This tag is applied to issues which reports bugs.
Modules: JSON
Bugs/feature requests, that are related to `json` and `x.json2` modules.
Modules: x.json2
Bugs related to *only* x.json2 (the pure V implementation)
Status: Confirmed
This bug has been confirmed to be valid by a contributor.
Unit: vlib
Bugs/feature requests, that are related to the vlib.
Describe the bug
The
json
parser silently discards numeric values which are quoted (which is sadly often encountered using external APIs).x.json2
properly casts these values into the desired numeric type.This behaviour was already reported in #13996 but the issue was closed without a solution.
Reproduction Steps
Expected Behavior
I expect
json.decode()
to either fail with an error describing which field couldn't be parsed, or try casting the values likejson2.decode()
does.Current Behavior
json
silently ignores the fields, which can lead to uncaught bugs in applications, i.e. when external APIs change their schema.Possible Solution
No response
Additional Information/Context
No response
V version
0.4.9 3953445
Environment details (OS name and version, etc.)
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: