convert sql query result to json