ITADN

Rules of schema-based parsing?

#50ClosedZhaiMo15 创建于 2024-05-22
Z
ZhaiMo15commented
Here's an example: ```java 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?
关闭于 2024-05-22 2 条评论