For JSON data that contains info about people, what do you think of the idea of using an array of strings for the name?
{
"workers": [
{
"name": ["John", "Doe"],
…
},
…
]
}
(as an alternative to having separate "firstName" and "lastName" fields)
worker.name.join(' ') // full name
worker.name.at(-1) // last name
It assumes names have a structure, but that is not always the case. So it depends on the culture and there is no simple correct answer.
If that's what you need, it will fail with Spanish names.
In Spain (and many other countries), a person's name is composed of the given name and two surnames, traditionally the father's first one and then the mother's. When searching by surname, we always search by the first one. The given name can be a single name or multiple.
For example, when searching "Pedro Sánchez Castejón", people would ask for "Sánchez", but you would not find it if you look into the last item of the array.
Even worse, there are even more complex names, like "José Manuel García-Margallo y Marfil", where the given name is "José Manuel", the first surname is "García-Margallo" and the last is "Marfil" (the "y" is a weird thing nobility does). Alphabetic order is complex too, in the same sense that it is for book titles. "The Illiad" goes before or after "Pride and Prejudice"? And "de la Mata" and "Mateos"?
I think you are getting into a very deep rabbit hole, unless you are always managing names of people of the same naming tradition.
It's more or less the same as addresses: they seem easy to structure, but when you look at the data, it is a daunting task.