Converting results from a SQL query to JSON format, is an important task if you are developing an iOS application which grab data from your web application.
For this tutorial I'm going to create a new database, named jsontest, in MySQL.
Then I'm going to create a simple table:
Last, let me populate the table with some data:
It's time to write some code.
The following code make a query to the database and then print out the results into a table.
It's time to output results in JSON format, I'm going to modify a few lines of code after the mysql_query statement:
Yeah! really nothing more.