Skip to content

Rules of schema-based parsing? #50

Closed
@ZhaiMo15

Description

@ZhaiMo15

Here's an example:

    private final SimdJsonParser simdJsonParser = new SimdJsonParser();

    record testClass(String name, long aaa, long bbb, long ccc) {
    }

    record testClass2(long aaa, long bbb, long ccc) {
    }

    byte[] json = "{\"name\": \"John\", \"age\": 30, \"aaa\": 1, \"bbb\": 2, \"ccc\": 3}".getBytes(UTF_8);

    simdJsonParser.parse(json, json.length, testClass.class); // Works fine

    simdJsonParser.parse(json, json.length, testClass2.class); // Error

As the comments, when parse to testClass, everything's fine.
However, when parse to testClass2, an error comes:
NullPointer Cannot read the array length because "key" is null

I'm confused, I thought the "record" is flexible that can contains entire or part of the elements.
Is there a limitation or a rule to use schema-based parsing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions