/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package grammar;

import org.json.JSONObject;
import org.json.JSONArray;
import org.json.JSONException;

/**
 *
 * @author Administrator
 */
public class GetCinema {
    public static String slots(String json)
            throws JSONException
    {


        StringBuffer cinemaRecoSB = new StringBuffer();
        String cinemas;

        try{
            JSONArray cinemasArray =   new JSONArray(json);
            for (int x=0; x<cinemasArray.length(); x++){
                JSONObject cinema = cinemasArray.getJSONObject(x);
                if(cinema.has("name") && cinema.has("recognition"))
                    cinemaRecoSB.append("(" + cinema.getString("recognition") + ") {<choice \"" + cinema.getString("name") + "\">}" + "\n");
            }
            cinemas = cinemaRecoSB.toString();
        }
        catch(JSONException e){
            cinemas = "";
        }

        return cinemas;
    }

}
