Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.List;

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

public class Main {
    public static String list_to_nice_string(List<Object> cuisines) {
        String out = "";
        for (Object aux : cuisines) {
            try {
                JSONObject jsonObj = new JSONObject(String.valueOf(aux));
                out = out + ", " + jsonObj.getString("name");
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        if (out.length() > 4) {
            return out.substring(0, out.length() - 2);
        } else {
            return "";
        }
    }
}