I pasted [] into the JSON converter and expected one answer. The four formats disagreed. [] is valid JSON. It is not an empty text box, and it is not a parse error. Conversion stays in the browser. Nothing is uploaded.
What each format prints
Laravel walks the whole value and prints an empty PHP array:
[]
TypeScript drafts from the first object when the root is an array. There is no first object, so the interface is empty Root with a blank line between the braces:
export interface Root {
}
The PHP DTO is still class DataTransferObject. It has declare(strict_types=1), no properties, and an empty constructor:
<?php
declare(strict_types=1);
class DataTransferObject
{
public function __construct(array $data = [])
{
}
}
CSV does not convert []. The error is CSV conversion expects an array of objects. and the output is cleared.
Not the same as a broken paste
A trailing comma such as {"a":1,} clears every format with Expected double-quoted property name in JSON at position 7 (line 1 column 8). A lone { stops at column 2. An empty box says Unexpected end of JSON input. Those are parse failures. [] parses. CSV is the format that still refuses it.
Repair broken JSON in the JSON formatter, then convert again. For CSV, paste an array of objects.
Guide: https://kepttools.com/guides/json-to-typescript-php-dto-laravel
Top comments (2)
In our CLI (Argon),
-o jsonemitsbranches: []for an empty result set, not empty stdout. Empty stdout is not valid JSON and breaksjqpipelines downstream. Four commands now register-o/--outputand emit the array literal:gc,restore --preview,restore --reset, andrestore --branch.That matches the empty-set case cleanly.
[]is still JSON, so jq and anything else that expects a document can keep going. Empty stdout is a different failure mode — the pipeline has nothing to parse.Keeping
-o jsonongcand the restore variants as an array literal is the right shape for that path. On the converter side we hit the same tension: Laravel can print[], while CSV still refuses because it wants rows of objects, not an empty list.