Codota Logo
JSONArray.addAll
Code IndexAdd Codota to your IDE (free)

How to use
addAll
method
in
org.json.simple.JSONArray

Best Java code snippets using org.json.simple.JSONArray.addAll (Showing top 20 results out of 315)

  • Common ways to obtain JSONArray
private void myMethod () {
JSONArray j =
  • Codota Iconnew JSONArray()
  • Codota IconJSONObject json;Object object;(JSONArray) json.get(object)
  • Codota IconString s;(JSONArray) JSONValue.parse(s)
  • Smart code suggestions by Codota
}
origin: jitsi/jitsi-videobridge

  private static String getJsonString(Collection<String> strings)
  {
    JSONArray array = new JSONArray();
    if (strings != null && !strings.isEmpty())
    {
      array.addAll(strings);
    }
    return array.toString();
  }
}
origin: rhuss/jolokia

/** {@inheritDoc} */
@Override
JSONObject toJson() {
  JSONObject ret = super.toJson();
  if (hasSingleAttribute()) {
    ret.put("attribute",attributes.get(0));
  } else if (!hasAllAttributes()) {
    JSONArray attrs = new JSONArray();
    attrs.addAll(attributes);
    ret.put("attribute",attrs);
  }
  if (path != null) {
    ret.put("path",path);
  }
  return ret;
}
origin: apache/metron

@SuppressWarnings({"unchecked"})
public JSONObject getJSONObject() {
 JSONObject errorMessage = new JSONObject();
 errorMessage.put(Constants.GUID, UUID.randomUUID().toString());
 errorMessage.put(Constants.SENSOR_TYPE, "error");
 if (sensorTypes.size() == 1) {
  errorMessage.put(ErrorFields.FAILED_SENSOR_TYPE.getName(), sensorTypes.iterator().next());
 } else {
  errorMessage
    .put(ErrorFields.FAILED_SENSOR_TYPE.getName(), new JSONArray().addAll(sensorTypes));
 }
 errorMessage.put(ErrorFields.ERROR_TYPE.getName(), errorType.getType());
 addMessageString(errorMessage);
   addStacktrace(errorMessage);
 addTimestamp(errorMessage);
 addHostname(errorMessage);
 addRawMessages(errorMessage);
 addErrorHash(errorMessage);
 return errorMessage;
}
origin: pellierd/pddl4j

  /**
   * Transform an ArrayList into a JSONArray.
   *
   * @param list an ArrayList that we want to convert into a List.
   * @return list the list parameter.
   */
  @SuppressWarnings("unchecked")
  private static JSONArray listToJson(List<String> list) {
    final JSONArray array = new JSONArray();
    array.addAll(list);
    return array;
  }
}
origin: quintona/storm-r

public JSONArray coerceTuple(TridentTuple tuple){
  JSONArray array = new JSONArray();
  array.addAll(tuple);
  return array;
}

origin: mayconbordin/storm-applications

public JSONObject toJSON(){
  JSONObject json = new JSONObject();
  json.put("@source", source);
  json.put("@timestamp", DateFormat.getDateInstance().format(timestamp));
  json.put("@source_host",sourceHost);
  json.put("@source_path",sourcePath);
  json.put("@message",message);
  json.put("@type",type);
  
  JSONArray temp = new JSONArray();
  temp.addAll(tags);
  json.put("@tags", temp);
  
  JSONObject fieldTemp = new JSONObject();
  fieldTemp.putAll(fields);
  json.put("@fields",fieldTemp);
  
  return json;
}
origin: com.googlecode.the-fascinator/fascinator-common

@SuppressWarnings(value = { "unchecked" })
private void mergeConfig(Map targetMap, Map srcMap) {
  for (Object key : srcMap.keySet()) {
    Object src = srcMap.get(key);
    Object target = targetMap.get(key);
    if (target == null) {
      targetMap.put(key, src);
    } else {
      if (src instanceof Map && target instanceof Map) {
        mergeConfig((Map) target, (Map) src);
      } else if (src instanceof JSONArray
          && target instanceof JSONArray) {
        JSONArray srcArray = (JSONArray) src;
        JSONArray targetArray = (JSONArray) target;
        targetArray.addAll(srcArray);
      } else {
        targetMap.put(key, src);
      }
    }
  }
}
origin: marcelo-mason/SimpleClans

/**
 * Return the list of flags and their data as a json string
 *
 * @return the flags
 */
public String getFlags() {
  JSONObject json = new JSONObject();
  // writing the list of flags to json
  JSONArray warring = new JSONArray();
  warring.addAll(warringClans.keySet());
  json.put("warring", warring);
  json.put("homeX", homeX);
  json.put("homeY", homeY);
  json.put("homeZ", homeZ);
  json.put("homeWorld", homeWorld == null ? "" : homeWorld);
  return json.toString();
}
origin: Lambda-3/Indra

  private static JSONObject toJSONObject(Map<String, Object> map) {
    JSONObject object = new JSONObject();

    for (String key : map.keySet()) {
      Object content = map.get(key);
      if (content instanceof Collection) {
        JSONArray array = new JSONArray();
        array.addAll((Collection<?>) content);
        object.put(key, array);
      } else if (content instanceof Map) {
        object.put(key, toJSONObject((Map<String, Object>) content));
      } else {
        object.put(key, content);
      }
    }

    return object;
  }
}
origin: io.hawt/hawtio-system

@Override
public void doGet(HttpServletRequest httpServletRequest,
         HttpServletResponse httpServletResponse) throws IOException, ServletException {
  InputStream propsIn = SpringBatchConfigServlet.class.getClassLoader().getResourceAsStream("springbatch.properties");
  httpServletResponse.setHeader("Content-type", "application/json");
  if (propsIn == null) {
    writeEmpty(httpServletResponse.getWriter());
    return;
  }
  Properties properties = new Properties();
  properties.load(propsIn);
  JSONObject responseJson = new JSONObject();
  JSONArray springBatchServersJson = new JSONArray();
  List<? extends String> springBatchServers = Arrays.asList(properties.getProperty("springBatchServerList").split(","));
  springBatchServersJson.addAll(springBatchServers);
  responseJson.put("springBatchServerList", springBatchServersJson);
  String res = "success";
  httpServletResponse.getWriter().println(responseJson.toJSONString());
}
origin: apache/oozie

@SuppressWarnings({"unchecked", "rawtypes"})
private JSONArray availableTimeZonesToJsonArray() {
  JSONArray array = new JSONArray();
  for (String tzId : TimeZone.getAvailableIDs()) {
    // skip id's that are like "Etc/GMT+01:00" because their display names are like "GMT-01:00", which is confusing
    if (!tzId.startsWith("Etc/GMT")) {
      JSONObject json = new JSONObject();
      TimeZone tZone = TimeZone.getTimeZone(tzId);
      json.put(JsonTags.TIME_ZOME_DISPLAY_NAME, tZone.getDisplayName(false, TimeZone.SHORT) + " (" + tzId + ")");
      json.put(JsonTags.TIME_ZONE_ID, tzId);
      array.add(json);
    }
  }
  // The combo box this populates cannot be edited, so the user can't type in GMT offsets (like in the CLI), so we'll add
  // in some hourly offsets here (though the user will not be able to use other offsets without editing the cookie manually
  // and they are not in order)
  array.addAll(GMTOffsetTimeZones);
  return array;
}
origin: org.apache.oozie/oozie-core

@SuppressWarnings({"unchecked", "rawtypes"})
private JSONArray availableTimeZonesToJsonArray() {
  JSONArray array = new JSONArray();
  for (String tzId : TimeZone.getAvailableIDs()) {
    // skip id's that are like "Etc/GMT+01:00" because their display names are like "GMT-01:00", which is confusing
    if (!tzId.startsWith("Etc/GMT")) {
      JSONObject json = new JSONObject();
      TimeZone tZone = TimeZone.getTimeZone(tzId);
      json.put(JsonTags.TIME_ZOME_DISPLAY_NAME, tZone.getDisplayName(false, TimeZone.SHORT) + " (" + tzId + ")");
      json.put(JsonTags.TIME_ZONE_ID, tzId);
      array.add(json);
    }
  }
  // The combo box this populates cannot be edited, so the user can't type in GMT offsets (like in the CLI), so we'll add
  // in some hourly offsets here (though the user will not be able to use other offsets without editing the cookie manually
  // and they are not in order)
  array.addAll(GMTOffsetTimeZones);
  return array;
}
origin: FutureCitiesCatapult/TomboloDigitalConnector

  @Override
  public JSONObject jsonValueForSubject(Subject subject, Boolean timeStamp) throws IncomputableFieldException {
    List<TimedValue> timedValues = TimedValueUtils.getBySubjectAndAttribute(subject, getAttribute());
    if (timedValues.isEmpty()) {
      throw new IncomputableFieldException(String.format("No TimedValue found for attribute %s", getAttribute().getLabel()));
    }
    JSONArray arr = new JSONArray();
    arr.addAll(timedValues.stream().map(timedValue -> {
      JSONObject pair = new JSONObject();
      pair.put("timestamp", timedValue.getId().getTimestamp().format(TimedValueId.DATE_TIME_FORMATTER));
      pair.put("value", timedValue.getValue());
      return pair;
      }).collect(Collectors.toList()));
    return withinMetadata(arr);
  }
}
origin: org.kuali.kpme/kpme-tk-lm-impl

errorMsgList.addAll(errors);
lraaForm.setOutputString(JSONValue.toJSONString(errorMsgList));
return mapping.findForward("ws");
origin: apache/oozie

JSONObject dependencyList = new JSONObject();
JSONArray jsonArray = new JSONArray();
jsonArray.addAll(dependencies.getSecond().get(key).getMissingDependencies());
dependencyList.put(JsonTags.COORDINATOR_ACTION_MISSING_DEPS, jsonArray);
dependencyList.put(JsonTags.COORDINATOR_ACTION_DATASET, key);
origin: org.kuali.kpme/kpme-tk-lm-impl

/**
 * This is an ajax call triggered after a user submits the leave entry form.
 * If there is any error, it will return error messages as a json object.
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return jsonObj
 * @throws Exception
 */
@SuppressWarnings("unchecked")
public ActionForward validateLeaveEntry(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
  LeaveCalendarWSForm lcf = (LeaveCalendarWSForm) form;
  JSONArray errorMsgList = new JSONArray();
  errorMsgList.addAll(LeaveCalendarValidationUtil.validateLeaveEntry(lcf));
  
  lcf.setOutputString(JSONValue.toJSONString(errorMsgList));
  
  return mapping.findForward("ws");
}
origin: apache/oozie

@SuppressWarnings("unchecked")
@Override
JSONArray getActionRetries(HttpServletRequest request, HttpServletResponse response)
    throws XServletException, IOException {
  JSONArray jsonArray = new JSONArray();
  String jobId = getResourceName(request);
  try {
    jsonArray.addAll(Services.get().get(DagEngineService.class).getDagEngine(getUser(request))
        .getWorkflowActionRetries(jobId));
    return jsonArray;
  }
  catch (BaseEngineException ex) {
    throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
  }
}
origin: org.apache.oozie/oozie-core

@SuppressWarnings("unchecked")
@Override
JSONArray getActionRetries(HttpServletRequest request, HttpServletResponse response)
    throws XServletException, IOException {
  JSONArray jsonArray = new JSONArray();
  String jobId = getResourceName(request);
  try {
    jsonArray.addAll(Services.get().get(DagEngineService.class).getDagEngine(getUser(request))
        .getWorkflowActionRetries(jobId));
    return jsonArray;
  }
  catch (BaseEngineException ex) {
    throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
  }
}
origin: com.googlecode.redbox-mint/redbox-web-service

@SuppressWarnings("unchecked")
@ApiOperation(value = "get information about the ReDBox instance", tags = "info")
@ApiResponses({
  @ApiResponse(code = 200, message = "The datastreams are listed"),
  @ApiResponse(code = 500, message = "Server configuration not found", response = IOException.class)
})
@Get("json")
public String getServerInformation() throws IOException{
  JsonObject responseObject = getSuccessResponse(null);
  JsonSimpleConfig config = new JsonSimpleConfig();
  responseObject.put("institution", config.getString(null, "identity","institution"));
  responseObject.put("applicationVersion", config.getString(null, "redbox.version.string"));
  JSONArray packageTypes = new JSONArray();
  if ("mint".equals(config.getString(null, "system"))) {
    packageTypes.addAll(getPackageTypesFromFileSystem());
  } else {
    JsonObject packageTypesObject = config.getObject("portal", "packageTypes");
    packageTypes.addAll(packageTypesObject.keySet());
  }
  
  
  responseObject.put("packageTypes", packageTypes);
  return new JsonSimple(responseObject).toString(true);
}
origin: com.googlecode.redbox-mint/redbox-web-service

@SuppressWarnings("unchecked")
@ApiOperation(value = "List datastreams in an object", tags = "datastream")
@ApiResponses({
  @ApiResponse(code = 200, message = "The datastreams are listed"),
  @ApiResponse(code = 500, message = "Oid does not exist in storage", response = StorageException.class)
})
@Get("json")
public JsonRepresentation getDatastreamList() throws StorageException, IOException {
  Storage storage = (Storage) ApplicationContextProvider.getApplicationContext().getBean("fascinatorStorage");
  String oid = getAttribute("oid");
  DigitalObject digitalObject = StorageUtils.getDigitalObject(storage, oid);
  JsonObject responseObject = getSuccessResponse(oid);
  JSONArray dataStreamIds = new JSONArray();
  dataStreamIds.addAll(digitalObject.getPayloadIdList());
  responseObject.put("datastreamIds", dataStreamIds);
  return new JsonRepresentation(new JsonSimple(responseObject).toString(true));
}

org.json.simpleJSONArrayaddAll

Popular methods of JSONArray

  • <init>
    Constructs a JSONArray containing the elements of the specified collection, in the order they are re
  • add
  • size
  • get
  • toJSONString
  • iterator
  • isEmpty
  • toString
  • toArray
  • writeJSONString
  • contains
  • remove
  • contains,
  • remove,
  • set,
  • clear,
  • forEach,
  • getJsonObject,
  • listIterator,
  • subList

Popular in Java

  • Reading from database using SQL prepared statement
  • notifyDataSetChanged (ArrayAdapter)
  • onCreateOptionsMenu (Activity)
  • onRequestPermissionsResult (Fragment)
  • ObjectMapper (com.fasterxml.jackson.databind)
    This mapper (or, data binder, or codec) provides functionality for converting between Java objects (
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • List (java.util)
    A List is a collection which maintains an ordering for its elements. Every element in the List has a
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now