feat: add to and from json functions#2473
Conversation
Add new methods to TypeScript marshalling preset: - toJson(): Record<string, unknown> - converts instance to plain object - fromJson(obj): ClassName - creates instance from plain object - marshal() now delegates to JSON.stringify(this.toJson()) - unmarshal() now delegates to fromJson() This enables working with parsed JSON objects directly without string serialization, useful for API responses or custom serialization. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
✅ Deploy Preview for modelina canceled.
|
|
|
Date marshal produces date-time output for date-only format renderDateMarshal generates identical JSON.stringify(payload) for both date and date-time formats, but JSON.stringify(Date) always calls Date.toISOString() producing a full date-time string like "2023-01-01T00:00:00.000Z". For format: "date" types (like FormatDate), AJV validation expects YYYY-MM-DD strings per RFC 3339. This causes the explicitly documented validate({data: marshal(obj)}) workflow to fail for date format types, and downstream systems expecting date-only strings will receive date-time strings instead. isDateFormatModel treats both formats identically but the marshal needs to produce format-appropriate output. |



Description
Related Issue
Checklist
npm run lint).npm run test).Additional Notes