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