Skip to content

Handle JSON null when reading object/array-typed properties - #73

Merged
noha merged 1 commit into
masterfrom
stripe-nested-nullable-read-fix
Jul 30, 2026
Merged

Handle JSON null when reading object/array-typed properties#73
noha merged 1 commit into
masterfrom
stripe-nested-nullable-read-fix

Conversation

@noha

@noha noha commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

JSONSchemaObject>>readUsing: and JSONSchemaArray>>readUsing: went straight to a structural parse (parseMapKeysDo:/parseListDo:, expecting { or [ respectively) with no concept of null, even though any property can legitimately be JSON null regardless of its declared type - Stripe's responses do this constantly (address, discount, items, and most other optional fields are null unless set). Added a shared JSONSchema>>peekNullThenReadUsing:ifNotNull: (uses parseConstantDo:, which does not consume the stream on a non-match, to peek for null/true/false before committing to the structural read) and wired both readUsing: methods through it. A literal true/false where an object/array was expected now raises a clear JSONTypeError instead of an opaque NeoJSONParseError ('{ expected'/'[ expected').

Found the same way as the rest of today's fixes: driving OpenApiClient against the real Stripe spec + a live stripe-mock instance. The full Customer and Subscription response bodies - both deeply nested, both full of null fields - now read back correctly end to end.

JSONSchemaObject>>readUsing: and JSONSchemaArray>>readUsing: went
straight to a structural parse (parseMapKeysDo:/parseListDo:, expecting
{ or [ respectively) with no concept of null, even though any property
can legitimately be JSON null regardless of its declared type - Stripe's
responses do this constantly (address, discount, items, and most other
optional fields are null unless set). Added a shared
JSONSchema>>peekNullThenReadUsing:ifNotNull: (uses parseConstantDo:, which
does not consume the stream on a non-match, to peek for null/true/false
before committing to the structural read) and wired both readUsing:
methods through it. A literal true/false where an object/array was
expected now raises a clear JSONTypeError instead of an opaque
NeoJSONParseError ('{ expected'/'[ expected').

Found the same way as the rest of today's fixes: driving OpenApiClient
against the real Stripe spec + a live stripe-mock instance. The full
Customer and Subscription response bodies - both deeply nested, both
full of null fields - now read back correctly end to end.
@noha
noha merged commit c2b4f61 into master Jul 30, 2026
3 of 4 checks passed
@noha
noha deleted the stripe-nested-nullable-read-fix branch July 30, 2026 12:18
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.

1 participant