X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=blobdiff_plain;f=src%2Fjalview%2Fjavascript%2Fjson%2FJSON.java;fp=src%2Fjalview%2Fjavascript%2Fjson%2FJSON.java;h=4e9d1dd5707d536428295dcf95921849f8a59cee;hp=0000000000000000000000000000000000000000;hb=e95c5f895775891d55d9f23d5da64f8ce6bd07bb;hpb=74f21ca6ca8fa17d53708e457d191e15904f8310 diff --git a/src/jalview/javascript/json/JSON.java b/src/jalview/javascript/json/JSON.java new file mode 100644 index 0000000..4e9d1dd --- /dev/null +++ b/src/jalview/javascript/json/JSON.java @@ -0,0 +1,61 @@ +package jalview.javascript.json; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.net.URL; + +/** + * + * A rudimentary JSON converter/iterator that uses the browser's native AJAX + * json data type delivery mechanism. + * + * Arrays are delivered as ArrayList where Object may be Boolean, + * String, Long, Double, ArrayList, and "Map-like object". + * + * For speed, the maps returned are just JavaScript maps with a few added + * methods for extracting data. [get(), contains(), probably should add keySet, + * valueSet, and entrySet]. + * + * @author hansonr Bob Hanson St. Olaf College 1/24/2019 + * + */ +public class JSON { + + /** + * A simple encoding of sequential key/value pairs for a jQuery.ajax call. If + * the first key is "url" and the second is an object, then the ajax object is + * attached to that url as well, just for transport purposes within the system. + * + * @param keyValues assumed to be simple String,Object pairs. String objects + * will be surrounded by double quotes. + */ + @SuppressWarnings("static-access") + public static Object setAjax(Object... keyValues) { + return /** @j2sNative swingjs.JSUtil.setAjax$OA(keyValues) || */null; + } + + public static void setAjax(URL url) { + /** @j2sNative swingjs.JSUtil.setAjax$java_net_URL(url); */ + } + + public static BufferedReader getJSONReader(InputStream is) { + return /** @j2sNative swingjs.JSUtil.getJSONReader$O(is) || */null; + } + + /** + * + * @param obj + * as String, Reader, InputStream, or JavaScript Object or Array + * @return Map or List + */ + public static Object parse(Object obj) + { + return /** @j2sNative swingjs.JSUtil.parseJSON$O(obj) || */ + null; + } + + public static String stringify(Object obj) { + return /** @j2sNative swingjs.JSUtil.stringifyJSON$O(obj) || */null; + } + +}