Menu

active is not a CSV header
📰

active is not a CSV header

DEV Community: laravel·Ameen Usman·10 days ago
#Ky1AMIuM
#devtolaravel#devto#dev#meta#cell
Reading 0:00
15s threshold

CSV does not split a nested object into columns. On the JSON converter , top-level keys become headers. A nest stays one cell. Conversion runs in the browser. Nothing is uploaded.

The sample shape

When meta holds {"active":true} , CSV prints a meta column. The cell is the nested object as JSON text, with quotes doubled so the row stays valid:

id,name,role,meta 1,Ada,engineer,"{""active"":true}"

Enter fullscreen mode

Exit fullscreen mode

active is not its own header. It stays inside that cell.

How the other formats treat the nest

Laravel still nests a PHP array for meta . TypeScript drafts interface Meta and types the field as Meta . The PHP DTO types meta as public array $meta with no child class. Same paste, four different shapes.

An array value is also one CSV cell. {"id":1,"tags":[]} converts to a tags cell of [] .

Keep parse errors separate

A trailing comma such as {"a":1,} clears every format.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.