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