#211 corrects swingjs.JSUtil.parseJSONRaw$S call
[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.io.Reader;
6 import java.net.URL;
7
8 /**
9  * 
10  * A rudimentary JSON converter/iterator that uses the browser's native AJAX
11  * json data type delivery mechanism.
12  * 
13  * Arrays are delivered as ArrayList<Object> where Object may be Boolean,
14  * String, Long, Double, ArrayList, and "Map-like object".
15  * 
16  * For speed, the maps returned are just JavaScript maps with a few added
17  * methods for extracting data. [get(), contains(), probably should add keySet,
18  * valueSet, and entrySet].
19  * 
20  * @author hansonr Bob Hanson St. Olaf College 1/24/2019
21  *
22  */
23 public class JSON {
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 system.
29          * 
30          * @param keyValues assumed to be simple String,Object pairs. String objects
31          *                  will be surrounded by double quotes.
32          */
33         @SuppressWarnings("static-access")
34         public static Object setAjax(Object... keyValues) {
35                 return /** @j2sNative swingjs.JSUtil.setAjax$OA(keyValues) || */null;
36         }
37
38         public static void setAjax(URL url) {
39                 /** @j2sNative swingjs.JSUtil.setAjax$O(url) */;
40         }
41
42         public static BufferedReader getJSONReader(InputStream is) {
43                 return /** @j2sNative swingjs.JSUtil.getJSONReader$O(is) || */null;
44         }
45
46         @SuppressWarnings("resource")
47         public static Object parse(String json) {  
48     return /** @j2sNative swingjs.JSUtil.parseJSONRaw$S(json) || */
49     null;
50         }
51
52         public static Object parse(Reader br) {
53                 return /** @j2sNative swingjs.JSUtil.parseJSON$O(br) || */null;
54         }
55
56         public static String stringify(Object obj) {
57                 // not actually implemented.  
58                 return /** @j2sNative swingjs.JSUtil.stringifyJSON$O(obj) || */null;
59         }
60
61 }