Repository navigation
Fix invalid JSON numbers from CSVRow::to_json - #334
Merged
vincentlaucsb merged 2 commits intoOct 10, 2026
Merged
Conversation
data_type() accepts numeric text that JSON does not: .5, 5., 1.e5, a space before a sign or zero, and 0x hex. Trim numeric fields, add the missing digit around the decimal point, and write hex integers in decimal.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #334 +/- ##
==========================================
- Coverage 91.60% 91.57% -0.04%
==========================================
Files 55 55
Lines 3574 3595 +21
Branches 1058 1068 +10
==========================================
+ Hits 3274 3292 +18
Misses 115 115
- Partials 185 188 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Owner
|
I added a padded hex edge case to the test suite. Thanks for your PR and for the detailed test suite. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #323/#325.
data_type()classifies some text as numeric that JSON doesn't accept as a number:.5,5.,1.e5, a space before a sign or zero (+2,08), and0xhex.to_json()/to_json_array()wrote those as-is, so a row like.5,5., 08 ,0x1Fproduced[.5,5., 08 ,0x1F], which JSON parsers reject (the README says the output is properly escaped).Numeric fields are now trimmed and given the missing digit around
., and hex integers are written in decimal (0x1F->31), the same valueCSVField::get()returns. Hex beyond int64 is still classified as a string and stays quoted.Added cases to
tests/test_csv_row_json.cpp; they fail before the change, and the JSON tests pass after it with the repo's-Werrorflags. I also fed random numeric strings throughto_json_arrayand checked the output with Python'sjson.loads: no invalid output remains, and every value equalsfloat(s)(orint(s, 16)).Written with AI assistance (Claude); I have reviewed the change.