Skip to content

Fix scientific floats #774

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

Merged
merged 2 commits into from
Jul 14, 2023
Merged

Fix scientific floats #774

merged 2 commits into from
Jul 14, 2023

Conversation

dmontagu
Copy link
Collaborator

@@ -146,7 +146,7 @@ impl<'de> Deserialize<'de> for JsonInput {

if let JsonInput::String(s) = &first_value {
// Normalize the string to either an int or float
let normalized = if s.contains('.') {
let normalized = if s.contains('.') || s.contains('e') {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there's a better way to do this check, or maybe there's a way to better-infer from serde_json itself that the value should be a number..? @davidhewitt @samuelcolvin @adriangb

Copy link
Collaborator Author

@dmontagu dmontagu Jul 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay after some unnecessarily thorough investigation (assisted by @adriangb, thanks) I'm pretty confident this approach is sufficiently optimized

@codecov
Copy link

codecov bot commented Jul 14, 2023

Codecov Report

Merging #774 (8b68498) into main (65aee42) will not change coverage.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #774   +/-   ##
=======================================
  Coverage   93.67%   93.67%           
=======================================
  Files          99       99           
  Lines       14290    14290           
  Branches       25       25           
=======================================
  Hits        13386    13386           
  Misses        898      898           
  Partials        6        6           
Impacted Files Coverage Δ
src/input/parse_json.rs 96.34% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65aee42...8b68498. Read the comment docs.

@codspeed-hq
Copy link

codspeed-hq bot commented Jul 14, 2023

CodSpeed Performance Report

Merging #774 will not alter performance

Comparing fix-scientific-floats (8b68498) with main (65aee42)

Summary

✅ 126 untouched benchmarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

model_validate_json Fails with exponential notation float
2 participants