Skip to content

Add readable JSON and binary helpers to generated structs - #2

Merged
happyDemon merged 2 commits into
mainfrom
serialization-formats
Nov 9, 2026
Merged

happyDemon merged 2 commits into
mainfrom
serialization-formats

Conversation

@happyDemon

Copy link
Copy Markdown
Member

Generated structs gain toReadableJson(), toBytes() and fromBytes(), placed after the existing dense JSON methods. fromBytes() hydrates through the same path as the existing dense "from" method, so validation still applies where the generator validates. There's no fromReadableJson(): the existing dense "from" method already accepts readable JSON.

Enums get the same methods from @php-skir/generator-core 0.2.0 (dependency bumped to ^0.2.0). Integration tests round-trip structs and enums through bytes and check readable output against the runtime.

CI is red until php-skir/runtime#2 is merged and @php-skir/generator-core 0.2.0 is published (php-skir/generator-core#1). The lockfile references 0.2.0 without an integrity hash because it isn't published yet. Run npm install once after publishing to fill it in.

Generated structs now expose toReadableJson(), toBytes() and fromBytes() next to the dense JSON helpers. fromBytes() hydrates through fromArray(), like fromDenseJson(). Requires @php-skir/generator-core ^0.2.0, which adds the same helpers to generated enums.
Locks @php-skir/generator-core 0.2.0 from the registry.
@happyDemon
happyDemon force-pushed the serialization-formats branch from 971d591 to 5d8e9b0 Compare November 9, 2026 11:48
@happyDemon
happyDemon merged commit 50b2415 into main Nov 9, 2026
3 checks passed
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