|
|
|
|
|
by dgb23
746 days ago
|
|
You can't fully replicate JSON schemas in either language without writing logic. In terms of just static definitions, Go has typed container types while PHP has not. That's a pretty common case for JSON. PHP is more convenient at another common case which is heterogeneous maps. Neither of those languages make me particularly happy in that regard. It also depends on what you're doing with the JSON. If you want/need to walk through it in a single pass fashion, then Go is definitely more fitting. |
|
I suggest looking at https://github.com/Crell/Serde, if that is a requirement in PHP.
> PHP is more convenient at another common case which is heterogeneous maps.
Or arbitrary, user-defined keys...
> If you want/need to walk through it in a single pass fashion, then Go is definitely more fitting.
array_map, array_reduce, array_column is pretty good at walking through arrays very quickly, assuming you parsed the json into arrays instead of objects.