JSON code moved to swingjs.json.JSON
[jalview.git] / src / jalview / javascript / json / JSON.java
1 package jalview.javascript.json;
2
3 import java.io.BufferedReader;
4 import java.io.IOException;
5 import java.io.InputStream;
6 import java.io.Reader;
7 import java.net.URL;
8 import java.util.ArrayList;
9 import java.util.Hashtable;
10 import java.util.Iterator;
11 import java.util.List;
12
13 /**
14  * 
15  * A rudimentary JSON converter/iterator that uses the browser's native AJAX
16  * json data type delivery mechanism.
17  * 
18  * Arrays are delivered as ArrayList<Object> where Object may be Boolean,
19  * String, Long, Double, ArrayList, and "Map-like object".
20  * 
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].
24  * 
25  * @author hansonr Bob Hanson St. Olaf College 1/24/2019
26  *
27  */
28 public class JSON {
29
30         /**
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.
34          * 
35          * @param keyValues assumed to be simple String,Object pairs. String objects
36          *                  will be surrounded by double quotes.
37          */
38         @SuppressWarnings("static-access")
39         public static Object setAjax(Object... keyValues) {
40                 return /** @j2sNative swingjs.JSUtil.setAjax$OA(keyValues) || */null;
41         }
42
43         public static void setAjax(URL url) {
44                 /** @j2sNative swingjs.JSUtil.setAjax$O(url) */;
45         }
46
47         public static BufferedReader getJSONReader(InputStream is) {
48                 return /** @j2sNative swingjs.JSUtil.getJSONReader$O(is) || */null;
49         }
50
51         @SuppressWarnings("resource")
52         public static Object parse(String json) {
53                 return /** @j2sNative swingjs.JSUtil.parseJSON$O(json) || */null;
54         }
55
56         public static Object parse(Reader br) {
57                 return /** @j2sNative swingjs.JSUtil.parseJSON$O(br) || */null;
58         }
59
60 }