Convert mysql data into json