Converting data from mysql database to jason format