Feature: add optional startup warning when db contains primitive arrays as resources
Author: tamjid14Created May 24, 2026Updated May 24, 2026
Feature proposal
When a top-level resource in db.json is an array of primitive values, such as strings or numbers, json-server can produce confusing behavior because resources usually need to be arrays of objects with id fields.
Example:
{
"roles": ["role-1", "role-2"]
}
This can lead to errors such as trying to create an id property on a string.
Suggested behavior
json-server could show a clear startup warning when a top-level resource contains primitive array items:
Warning: "roles" contains primitive values. Resources should usually be arrays of objects with id fields.
Why this helps
This would make the error easier to understand for beginners and would point users toward the expected structure:
{
"roles": [
{ "id": "role-1", "name": "role-1" },
{ "id": "role-2", "name": "role-2" }
]
}
This feature would not need to block startup. A warning may be enough to help users fix their database structure.
Source: typicode/json-server