quinnj / JSON3.jl

Other
214 stars 47 forks source link

Handle lots of fields #284

Closed Naunet closed 17 hours ago

Naunet commented 2 months ago

The test case LotsOfFields only works because all of the fields have the same value. The actual code is allocating the first 32 (DEFAULT_STRUCT_FIELD_COUNT) fields to the correct position but then using the JSON order to define any other fields. If we rearrange the fields in the JSON and use unique values then the result is wrong (see the new test).

I propose to use the fieldcount function instead of a constant to determine the number of fields. The documentation states that this function may throw an error but I'm not sure that the rest of JSON3 can handle such abstract cases, and there are no test cases currently defined that are failing.

An error is thrown if the type is too abstract to determine this.