2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.javascript.json;
23 import java.io.BufferedReader;
24 import java.io.InputStream;
29 * A rudimentary JSON converter/iterator that uses the browser's native AJAX
30 * json data type delivery mechanism.
32 * Arrays are delivered as ArrayList<Object> where Object may be Boolean,
33 * String, Long, Double, ArrayList, and "Map-like object".
35 * For speed, the maps returned are just JavaScript maps with a few added
36 * methods for extracting data. [get(), contains(), probably should add keySet,
37 * valueSet, and entrySet].
39 * @author hansonr Bob Hanson St. Olaf College 1/24/2019
46 * A simple encoding of sequential key/value pairs for a jQuery.ajax call. If
47 * the first key is "url" and the second is an object, then the ajax object is
48 * attached to that url as well, just for transport purposes within the
52 * assumed to be simple String,Object pairs. String objects will be
53 * surrounded by double quotes.
55 @SuppressWarnings("static-access")
56 public static Object setAjax(Object... keyValues)
58 return /** @j2sNative swingjs.JSUtil.setAjax$OA(keyValues) || */
62 public static void setAjax(URL url)
64 /** @j2sNative swingjs.JSUtil.setAjax$java_net_URL(url); */
67 public static BufferedReader getJSONReader(InputStream is)
69 return /** @j2sNative swingjs.JSUtil.getJSONReader$O(is) || */
76 * as String, Reader, InputStream, or JavaScript Object or Array
79 public static Object parse(Object obj)
81 return /** @j2sNative swingjs.JSUtil.parseJSON$O(obj) || */
85 public static String stringify(Object obj)
87 return /** @j2sNative swingjs.JSUtil.stringifyJSON$O(obj) || */