how can i create a JSON object from different tables( MySQL database) to consume in android project : this is my api, how can I converted to JSON Object using JAVA?

    



    $sql1="SELECT s.* , c.*,u.* FROM schedule_ s,course_t c, u user_t WHERE c.course_crn=p.course_crn and
     s.teacher_id=u.employee_id" ;


   $result=mysqli_query($con,$sql1);



      if($result)
    {
       while($row=mysqli_fetch_array($result))
     {
      $data[]=$row;
      }

       print(json_encode($data));