by slight · 11y ago · 0 comments
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.
In your preferred way, data is exchanged over HTTP which uses percent encoding to pass data. I'm stating that a serialized object, in this case JSON, provides more benefit.
Both require overhead to encode and decode, but I believe that serializing your data allows for a more consistent exchange that (provided I am understanding how you post and retrieve data) actually may reduce size, increase the variance of what can be transmitted, and remove specific limitations that HTTP may encounter.
I'm genuinely curious if I am missing something.