ff5dc44d722db54bb328789eb5cc68479e254c9b
[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   /**
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
29    * system.
30    * 
31    * @param keyValues
32    *          assumed to be simple String,Object pairs. String objects will be
33    *          surrounded by double quotes.
34    */
35   @SuppressWarnings("static-access")
36   public static Object setAjax(Object... keyValues)
37   {
38     return /** @j2sNative swingjs.JSUtil.setAjax$OA(keyValues) || */
39     null;
40   }
41
42   public static void setAjax(URL url)
43   {
44     /** @j2sNative swingjs.JSUtil.setAjax$java_net_URL(url); */
45   }
46
47   public static BufferedReader getJSONReader(InputStream is)
48   {
49     return /** @j2sNative swingjs.JSUtil.getJSONReader$O(is) || */
50     null;
51   }
52
53   /**
54    * 
55    * @param obj
56    *          as String, Reader, InputStream, or JavaScript Object or Array
57    * @return Map or List
58    */
59   public static Object parse(Object obj)
60   {
61     return /** @j2sNative swingjs.JSUtil.parseJSON$O(obj) || */
62     null;
63   }
64
65   public static String stringify(Object obj)
66   {
67     return /** @j2sNative swingjs.JSUtil.stringifyJSON$O(obj) || */
68     null;
69   }
70
71 }