1 package jalview.javascript.json;
3 import java.io.BufferedReader;
4 import java.io.InputStream;
10 * A rudimentary JSON converter/iterator that uses the browser's native AJAX
11 * json data type delivery mechanism.
13 * Arrays are delivered as ArrayList<Object> where Object may be Boolean,
14 * String, Long, Double, ArrayList, and "Map-like object".
16 * For speed, the maps returned are just JavaScript maps with a few added
17 * methods for extracting data. [get(), contains(), probably should add keySet,
18 * valueSet, and entrySet].
20 * @author hansonr Bob Hanson St. Olaf College 1/24/2019
26 * A simple encoding of sequential key/value pairs for a jQuery.ajax call. If
27 * the first key is "url" and the second is an object, then the ajax object is
28 * attached to that url as well, just for transport purposes within the system.
30 * @param keyValues assumed to be simple String,Object pairs. String objects
31 * will be surrounded by double quotes.
33 @SuppressWarnings("static-access")
34 public static Object setAjax(Object... keyValues) {
35 return /** @j2sNative swingjs.JSUtil.setAjax$OA(keyValues) || */null;
38 public static void setAjax(URL url) {
39 /** @j2sNative swingjs.JSUtil.setAjax$O(url) */;
42 public static BufferedReader getJSONReader(InputStream is) {
43 return /** @j2sNative swingjs.JSUtil.getJSONReader$O(is) || */null;
46 @SuppressWarnings("resource")
47 public static Object parse(String json) {
48 return /** @j2sNative swingjs.JSUtil.parseJSONRaw$S(json) || */
52 public static Object parse(Reader br) {
53 return /** @j2sNative swingjs.JSUtil.parseJSON$O(br) || */null;
56 public static String stringify(Object obj) {
57 // not actually implemented.
58 return /** @j2sNative swingjs.JSUtil.stringifyJSON$O(obj) || */null;