first-name keeps the hyphen in the draft
A key named first-name looks fine in JSON. The drafts do not treat it the same way. On the JSON converter , Laravel quotes it and stays valid. TypeScript and the PHP DTO keep the hyphen in the identifier. Conversion runs in the browser. Nothing is uploaded. The sample { "first-name" : "Ada" , "role" : "engineer" } Laravel prints valid array syntax: 'first-name' => 'Ada' . TypeScript emits…
A key named "first-name" functions correctly in JSON format. However, when converted to Laravel drafts, the hyphenated identifier behaves differently. Laravel encloses the hyphenated key in quotes, resulting in valid array syntax, such as "first-name" = Ada. TypeScript and PHP Data Transfer Objects (DTOs) retain the hyphen in the identifier, displaying it as first-name: string; in TypeScript and public string $first-name in the PHP class.
This draft is not intended for production use, but if the hyphen is not permissible in your language, it is advisable to rename the field before deployment.
The issue of a trailing comma, like { a:1,}, leads to parse errors and should be addressed by repairing the JSON formatter before conversion. Nested objects under the meta key become an interface named Meta in TypeScript and a public array $meta in the PHP class. The key itself is copied into the draft, irrespective of the hyphen. For further assistance, refer to the guide at https://kepttools.com/guides/json-to-typescript-php-dto-laravel.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.