@Override protected synchronized JSON data() { JSONArray d = JSONArray.fromObject(results); results.clear(); return d; }
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { rsp.setContentType(Flavor.JSON.contentType); PrintWriter w = rsp.getWriter(); JSONArray.fromObject(this).write(w); } }
initialPluginList = JSONArray.fromObject(initialPluginJson); break updateSiteList; } catch(Exception e) { URL localPluginData = cl.getResource("jenkins/install/platform-plugins.json"); String initialPluginJson = IOUtils.toString(localPluginData.openStream(), "utf-8"); initialPluginList = JSONArray.fromObject(initialPluginJson); } catch (Exception e) { LOGGER.log(Level.SEVERE, e.getMessage(), e);
for (Object o : JSONArray.fromObject(formData)) { JSONObject jo = (JSONObject)o; Descriptor<T> d = null;
/** * @param str a JSON array representation of a list of {@link AuthorityURLInfo} objects * @return the list of parsed authrority URL from the argument JSON array * @throws IllegalArgumentException if {@code str} can't be parsed to a JSONArray */ public static List<AuthorityURLInfo> fromString(String str) throws IllegalArgumentException { try { final JSONArray array; array = JSONArray.fromObject(str); final int size = array.size(); List<AuthorityURLInfo> list = new ArrayList<AuthorityURLInfo>(size); JSONObject jsonAuth; for (int i = 0; i < size; i++) { jsonAuth = array.getJSONObject(i); AuthorityURL auth = new AuthorityURL(); auth.setName(jsonAuth.getString(NAME)); auth.setHref(jsonAuth.getString(HREF)); list.add(auth); } return list; } catch (JSONException e) { throw new IllegalArgumentException(e.getMessage(), e); } }
/** * @param str a JSON array representation of a list of {@link LayerIdentifierInfo} objects * @return the list of parsed layer identifiers from the argument JSON array * @throws IllegalArgumentException if {@code str} can't be parsed to a JSONArray */ public static List<LayerIdentifierInfo> fromString(String str) throws IllegalArgumentException { try { final JSONArray array; array = JSONArray.fromObject(str); final int size = array.size(); List<LayerIdentifierInfo> list = new ArrayList<LayerIdentifierInfo>(size); JSONObject jsonAuth; for (int i = 0; i < size; i++) { jsonAuth = array.getJSONObject(i); LayerIdentifier id = new LayerIdentifier(); id.setAuthority(jsonAuth.getString(AUTHORITY)); id.setIdentifier(jsonAuth.getString(IDENTIFIER)); list.add(id); } return list; } catch (JSONException e) { throw new IllegalArgumentException(e.getMessage(), e); } }
JSONArray pluginCategories = JSONArray.fromObject(getPlatformPluginList().toString()); for (Iterator<?> categoryIterator = pluginCategories.iterator(); categoryIterator.hasNext();) { Object category = categoryIterator.next();
JSONArray a = JSONArray.fromObject(formData.get("parameter"));
/** * Retrieves the body of the request as a JSONArray object. (such as listing database names) * @return */ public JSONArray getBodyAsJSONArray() { if (body == null) return null; return JSONArray.fromObject(body); }
@Override protected synchronized JSON data() { JSONArray d = JSONArray.fromObject(results); results.clear(); return d; }
/** * 数组,集合等转json * @param bean * @param jsonConfig * @return * @author 唐延波 * @date 2015年7月6日 */ private String arrayToJson(Object bean){ JSONArray jsonArray = JSONArray.fromObject(bean, jsonConfig); return jsonArray.toString(); }
public static <T extends Describable<T>> List<T> newInstancesFromHeteroList(StaplerRequest req, Object formData, Collection<? extends Descriptor<T>> descriptors) throws FormException { List<T> items = new ArrayList<T>(); if (formData != null) { for (Object o : JSONArray.fromObject(formData)) { JSONObject jo = (JSONObject) o; String kind = jo.getString("kind"); items.add(find(descriptors, kind).newInstance(req, jo)); } } return items; }
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { rsp.setContentType(Flavor.JSON.contentType); PrintWriter w = rsp.getWriter(); w.print('('); JSONArray.fromObject(this).write(w); w.print(')'); } }
private String formatJSON(String json) { if (json.startsWith("[") && json.endsWith("]")) { return JSONArray.fromObject(json).toString(4); } else { return JSONObject.fromObject(json).toString(4); } }
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { rsp.setContentType(Flavor.JSON.contentType); PrintWriter w = rsp.getWriter(); w.print('('); JSONArray.fromObject(this).write(w); w.print(')'); } }
@SuppressWarnings("unchecked") @Override public <T> List<T> toList(String json, Class<T> beanClass) { JSONArray jsonArray = JSONArray.fromObject(json); List<T> list = (List<T>) JSONArray.toList(jsonArray, beanClass, getJsonConfig()); return list; }
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { rsp.setContentType(Flavor.JSON.contentType); PrintWriter w = rsp.getWriter(); w.print('('); JSONArray.fromObject(this).write(w); w.print(')'); } }
public String fromObject(ActionInvocation invocation, Object obj, String resultCode, Writer stream) throws IOException { if (obj != null) { if (isArray(obj)) { JSONArray jsonArray = JSONArray.fromObject(obj); stream.write(jsonArray.toString()); } else { JSONObject jsonObject = JSONObject.fromObject(obj); stream.write(jsonObject.toString()); } } return null; }
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { rsp.setContentType(Flavor.JSON.contentType); PrintWriter w = rsp.getWriter(); JSONArray.fromObject(this).write(w); } }
public void FromJsonString(String machineListString) throws LogException { try { JSONArray machineArray = JSONArray.fromObject(machineListString); FromJsonArray(machineArray); } catch (JSONException e) { throw new LogException("FailToGenerateMachineGroup", e.getMessage(), e, ""); } } }