[] is valid JSON. CSV still refuses it
Laravel prints []. TypeScript prints an empty Root. The PHP DTO is empty. CSV expects an array of objects.
![[] is valid JSON. CSV still refuses it](https://cdn.hashnode.com/uploads/covers/6acdedf030c1cb3b7081ed53/02815888-05e9-4632-ad35-ca7f72a979e5.png)
[] parses. It is not the empty-box error, and it is not a trailing-comma failure. On the JSON converter the four formats still disagree. Conversion runs in the browser.
Laravel prints []. TypeScript prints an empty Root:
export interface Root {
}
The PHP class is still named DataTransferObject. It has declare(strict_types=1), no fields, and a constructor with an empty body. CSV rejects the paste with CSV conversion expects an array of objects. and clears that output.
Why CSV refuses a valid array
CSV from this converter expects an array of objects so it can build a header from top-level keys. An empty array has no objects and no keys. A scalar list such as [1,"a",true,null] is also rejected for CSV, while Laravel can still print a PHP list of those values. TypeScript prints export interface Root {} when the first item is not an object. The PHP DTO then prints a stub whose only body is the comment Provide a JSON object to generate properties.
Keep the cases separate
| Paste | Result |
|---|---|
[] |
Valid JSON; CSV refuses |
{"a":1,} |
Parse error; all outputs cleared |
| empty box | Unexpected end of JSON input |
Fix broken text in the JSON formatter. For CSV, use an array of objects.
Guide: https://kepttools.com/guides/json-to-typescript-php-dto-laravel
Comments
Join the discussionNo comments yet. Be the first to comment.




