I have seen some tutorials and some stackoverflow discussions on how to send data from android to php page. most of the cases i have seen people sending data in string format but returning in json format. My question is that is it better to send data from android to php in json format. or in what cases i should use json over string.
Regards
2
Why do most people send just a string to a php page, instead of a JSON object? Probably because they just need to send one item of data; usually it’s an ID, like a Customer ID.
JSON is a structured data format. It works seamlessly with Javascript, and benefits from the easy availability of well-written parsers. It is used to return an object containing fields of data.
To do the same things as JSON does using strings, you would have to
- Come up with a data format,
- Write a parser for it, and
- Map the resulting data fields to Javascript variables.
All that work is already done for you, if you choose JSON. That’s why it is used to return, for example, a customer record from a database.