2

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
  • 1
    Can you link to one of those discussions, cause I don't understand what you are asking here? Mar 8 '13 at 15:20
  • 1
    "string" is not a format. A "string" format is the way a string is organized. Json is a string format (with specific requirements). 'Plan Text' is a string format (with very loose requirements). Mar 8 '13 at 16:45
1

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

  1. Come up with a data format,
  2. Write a parser for it, and
  3. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.