Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

On-demand double parsing breaks on integer values #70

Copy link
Copy link
@SamCarlberg

Description

@SamCarlberg
Issue body actions

If a JSON stream contains an integer number, SimdJsonParser will throw a parse exception if it's given a schema where that number is represented as a double. This applies to bare numbers, object values, and array entries:

// All of these throw a parse exception
double rawDouble = new SimdJsonParser().parse("1".getBytes(UTF_8), 1, double.class);
double[] array = new SimdJsonParser().parse("[1, 2]".getBytes(UTF_8), 6, double[].class);
HasDouble box = new SimdJsonParser().parse("{\"value\": 1}".getBytes(UTF_8), 12, HasDouble.class);

record HasDouble(double value) {}

As far as I can tell, this is because NumberParser.parseDouble requires double literals to either have a decimal point or exponent part. Should that be the case? I would expect integer number values to be permitted, since they can always be widened to doubles

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.