3 import java.io.IOException;
7 import org.json.simple.parser.ParseException;
13 * Converts a JSONArray of values to a string as a comma-separated list.
14 * Answers null if the array is null or empty.
19 public static String arrayToStringList(List<Object> jsonArray)
23 if (jsonArray == null || (n = jsonArray.size()) == 0)
29 * BH TODO to Platform?
33 * return jsonArray.elementData.slice(0, n).join(",");
36 StringBuilder sb = new StringBuilder();
37 for (int i = 0; i < n; i++)
43 sb.append(jsonArray.get(i).toString());
50 * The method all JSON parsing must go through for JavaScript.
53 * a BufferedReader or a javascript.json.JSON.JSONReader
56 * @throws ParseException
58 public static Object parse(Reader r) throws IOException, ParseException
60 return Platform.parseJSON(r);
63 public static Object parse(String json) throws ParseException
65 return Platform.parseJSON(json);
68 public static String stringify(Object obj)
70 return new org.json.JSONObject(obj).toString();