by ars · 11y ago · 0 comments
If you did send everything as JSON you would be bypassing everything PHP does with form/url data to make things easier for you (for example arrays). That doesn't seem like a good engineering tradeoff.
And then you can't make a request to the server directly unless you format your data as JSON, which is a bit inconvenient, especially if you're debugging a problem.
So if using JSON as a container isn't gaining you some other benefit then it's probably best avoided.
That's how we've done it here and the modularization it has provided us has been incredible. PHP's json_encode and json_decode are also quite fast.
I'm not saying using JSON as an envelope won't work - it is clearly working for you - just that I wouldn't start there, and I can't see that you couldn't work with the request object directly.