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