Tabnine Logo
JSONArray.add
Code IndexAdd Tabnine to your IDE (free)

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

Best Java code snippets using org.json.simple.JSONArray.add (Showing top 20 results out of 1,197)

Refine searchRefine arrow

  • JSONArray.<init>
  • JSONObject.put
  • JSONObject.<init>
origin: shopizer-ecommerce/shopizer

@SuppressWarnings("unchecked")
@Override
public String toJSONString() {
  JSONArray jsonArray = new JSONArray();
  for(String kw : keywords) {
    JSONObject data = new JSONObject();
    data.put("name", kw);
    data.put("value", kw);
    jsonArray.add(data);
  }
  return jsonArray.toJSONString();
}
origin: pentaho/pentaho-kettle

@SuppressWarnings( "unchecked" )
private String buildJsonQueryResult( QueryResult queryResult ) throws KettleException {
 JSONArray list = new JSONArray();
 for ( SObject sobject : queryResult.getRecords() ) {
  list.add( buildJSONSObject( sobject ) );
 }
 StringWriter sw = new StringWriter();
 try {
  list.writeJSONString( sw );
 } catch ( IOException e ) {
  throw new KettleException( e );
 }
 return sw.toString();
}
origin: pentaho/pentaho-kettle

public JSONArray storeRecentSearch( String recentSearch ) {
 JSONArray recentSearches = getRecentSearches();
 try {
  if ( recentSearch == null || recentSearches.contains( recentSearch ) ) {
   return recentSearches;
  }
  recentSearches.add( recentSearch );
  if ( recentSearches.size() > 5 ) {
   recentSearches.remove( 0 );
  }
  PropsUI props = PropsUI.getInstance();
  String jsonValue = props.getRecentSearches();
  JSONParser jsonParser = new JSONParser();
  JSONObject jsonObject = jsonValue != null ? (JSONObject) jsonParser.parse( jsonValue ) : new JSONObject();
  jsonObject.put( getLogin(), recentSearches );
  props.setRecentSearches( jsonObject.toJSONString() );
 } catch ( Exception e ) {
  e.printStackTrace();
 }
 return recentSearches;
}
origin: rhuss/jolokia

  /** {@inheritDoc} */
  @Override
  JSONObject toJson() {
    JSONObject ret = super.toJson();
    ret.put("operation",operation);
    if (arguments.size() > 0) {
      JSONArray args = new JSONArray();
      for (Object arg : arguments) {
        args.add(serializeArgumentToJson(arg));
      }
      ret.put("arguments",args);
    }
    return ret;
  }
}
origin: linkedin/indextank-engine

@SuppressWarnings("unchecked")
private void addResult(JSONArray ja, SearchResult result) {
  JSONObject document = new JSONObject();
  document.putAll(result.getFields());
  document.put("docid", result.getDocId());
  document.put("query_relevance_score", result.getScore());
  for(Entry<Integer, Double> entry: result.getVariables().entrySet()) {
    document.put("variable_" + entry.getKey(), entry.getValue());
  }
  for(Entry<String, String> entry: result.getCategories().entrySet()) {
    document.put("category_" + entry.getKey(), entry.getValue());
  }
  ja.add(document);
}
origin: GlowstoneMC/Glowstone

/**
 * Saves to the file.
 */
@SuppressWarnings("unchecked")
protected void save() {
  JSONArray array = new JSONArray();
  for (BaseEntry entry : entries) {
    JSONObject obj = new JSONObject();
    for (Entry<String, String> mapEntry : entry.write().entrySet()) {
      obj.put(mapEntry.getKey(), mapEntry.getValue());
    }
    array.add(obj);
  }
  try (Writer writer = new FileWriter(file)) {
    array.writeJSONString(writer);
  } catch (Exception ex) {
    GlowServer.logger.log(Level.SEVERE, "Error writing to: " + file, ex);
  }
}
origin: pentaho/pentaho-kettle

JSONObject jo = new JSONObject();
  jo.put( outputField.getElementName(), data.inputRowMeta.getBoolean( row, data.fieldIndexes[i] ) );
  break;
 case ValueMetaInterface.TYPE_INTEGER:
  jo.put( outputField.getElementName(), data.inputRowMeta.getInteger( row, data.fieldIndexes[i] ) );
  break;
 case ValueMetaInterface.TYPE_NUMBER:
  jo.put( outputField.getElementName(), data.inputRowMeta.getNumber( row, data.fieldIndexes[i] ) );
  break;
 case ValueMetaInterface.TYPE_BIGNUMBER:
  break;
data.ja.add( jo );
origin: Netflix/Priam

public AbstractBackupPath set(List<AbstractBackupPath> bps, String snapshotName)
    throws Exception {
  File metafile = createTmpMetaFile();
  try (FileWriter fr = new FileWriter(metafile)) {
    JSONArray jsonObj = new JSONArray();
    for (AbstractBackupPath filePath : bps) jsonObj.add(filePath.getRemotePath());
    fr.write(jsonObj.toJSONString());
  }
  AbstractBackupPath backupfile = decorateMetaJson(metafile, snapshotName);
  fs.uploadFile(
      Paths.get(backupfile.getBackupFile().getAbsolutePath()),
      Paths.get(backupfile.getRemotePath()),
      backupfile,
      10,
      true);
  addToRemotePath(backupfile.getRemotePath());
  return backupfile;
}
origin: org.apache.clerezza/jaxrs.rdf.providers

  private void createVariables(List<String> variables, JSONObject head) {
    JSONArray vars = null;
    for (String variable : variables) {
      if (vars == null) {
        vars = new JSONArray();
        head.put("vars", vars);
      }
      vars.add(variable);
    }
  }
}
origin: pentaho/pentaho-kettle

@SuppressWarnings( "unchecked" )
public String getDatabases() {
 JSONArray list = new JSONArray();
 for ( int i = 0; i < repositoriesMeta.nrDatabases(); i++ ) {
  JSONObject databaseJSON = new JSONObject();
  databaseJSON.put( "name", repositoriesMeta.getDatabase( i ).getName() );
  list.add( databaseJSON );
 }
 return list.toString();
}
origin: pentaho/pentaho-kettle

public void execute( Object[] row ) throws KettleException {
 JSONObject jo = new JSONObject();
    jo.put( outputField.getElementName(), data.inputRowMeta.getBoolean( row, data.fieldIndexes[i] ) );
    break;
   case ValueMetaInterface.TYPE_INTEGER:
    jo.put( outputField.getElementName(), data.inputRowMeta.getInteger( row, data.fieldIndexes[i] ) );
    break;
   case ValueMetaInterface.TYPE_NUMBER:
    jo.put( outputField.getElementName(), data.inputRowMeta.getNumber( row, data.fieldIndexes[i] ) );
    break;
   case ValueMetaInterface.TYPE_BIGNUMBER:
 data.ja.add( jo );
origin: Netflix/Priam

@Override
protected void downloadFileImpl(Path remotePath, Path localPath) throws BackupRestoreException {
  AbstractBackupPath path = pathProvider.get();
  path.parseRemote(remotePath.toString());
  if (path.getType() == AbstractBackupPath.BackupFileType.META) {
    // List all files and generate the file
    try (FileWriter fr = new FileWriter(localPath.toFile())) {
      JSONArray jsonObj = new JSONArray();
      for (AbstractBackupPath filePath : flist) {
        if (filePath.type == AbstractBackupPath.BackupFileType.SNAP
            && filePath.time.equals(path.time)) {
          jsonObj.add(filePath.getRemotePath());
        }
      }
      fr.write(jsonObj.toJSONString());
      fr.flush();
    } catch (IOException io) {
      throw new BackupRestoreException(io.getMessage(), io);
    }
  }
  downloadedFiles.add(remotePath.toString());
}
origin: apache/clerezza

  private void createVariables(List<String> variables, JSONObject head) {
    JSONArray vars = null;
    for (String variable : variables) {
      if (vars == null) {
        vars = new JSONArray();
        head.put("vars", vars);
      }
      vars.add(variable);
    }
  }
}
origin: pentaho/pentaho-kettle

@SuppressWarnings( "unchecked" )
public String getPlugins() {
 List<PluginInterface> plugins = pluginRegistry.getPlugins( RepositoryPluginType.class );
 JSONArray list = new JSONArray();
 for ( PluginInterface pluginInterface : plugins ) {
  if ( !pluginInterface.getIds()[0].equals( "PentahoEnterpriseRepository" ) ) {
   JSONObject repoJSON = new JSONObject();
   repoJSON.put( "id", pluginInterface.getIds()[ 0 ] );
   repoJSON.put( "name", pluginInterface.getName() );
   repoJSON.put( "description", pluginInterface.getDescription() );
   list.add( repoJSON );
  }
 }
 return list.toString();
}
origin: apache/oozie

@SuppressWarnings({"unchecked", "rawtypes"})
private static void prepareGMTOffsetTimeZones() {
  for (String tzId : new String[]{"GMT-12:00", "GMT-11:00", "GMT-10:00", "GMT-09:00", "GMT-08:00", "GMT-07:00", "GMT-06:00",
                  "GMT-05:00", "GMT-04:00", "GMT-03:00", "GMT-02:00", "GMT-01:00", "GMT+01:00", "GMT+02:00",
                  "GMT+03:00", "GMT+04:00", "GMT+05:00", "GMT+06:00", "GMT+07:00", "GMT+08:00", "GMT+09:00",
                  "GMT+10:00", "GMT+11:00", "GMT+12:00"}) {
    TimeZone tz = TimeZone.getTimeZone(tzId);
    JSONObject json = new JSONObject();
    json.put(JsonTags.TIME_ZOME_DISPLAY_NAME, tz.getDisplayName(false, TimeZone.SHORT) + " (" + tzId + ")");
    json.put(JsonTags.TIME_ZONE_ID, tzId);
    GMTOffsetTimeZones.add(json);
  }
}
origin: jitsi/jitsi-videobridge

public static JSONArray serializeSSRCs(int[] ssrcs)
{
  JSONArray ssrcsJSONArray;
  if (ssrcs == null)
  {
    ssrcsJSONArray = null;
  }
  else
  {
    ssrcsJSONArray = new JSONArray();
    for (int i = 0; i < ssrcs.length; i++)
      ssrcsJSONArray.add(Long.valueOf(ssrcs[i] & 0xFFFFFFFFL));
  }
  return ssrcsJSONArray;
}
origin: renepickhardt/metalcon

  /**
   * add the news stream according to the Activitystrea.ms format
   * 
   * @param activities
   *            news stream items
   */
  @SuppressWarnings("unchecked")
  public void addActivityStream(final List<JSONObject> activities) {
    final JSONArray items = new JSONArray();
    for (JSONObject activity : activities) {
      items.add(activity);
    }
    this.json.put("items", items);
  }
}
origin: shopizer-ecommerce/shopizer

JSONObject obj = new JSONObject();
obj.put("name", this.getName());
obj.put("price", this.getPrice());
obj.put("description", this.getDescription());
obj.put("highlight", this.getHighlight());
obj.put("store", this.getStore());
obj.put("id", this.getId());
if(categories!=null) {
  JSONArray categoriesArray = new JSONArray();
  for(String category : categories) {
    categoriesArray.add(category);
  obj.put("categories", categoriesArray);
  JSONArray tagsArray = new JSONArray();
  for(String tag : tags) {
    tagsArray.add(tag);
  obj.put("tags", tagsArray);
origin: org.apache.oozie/oozie-core

@SuppressWarnings({"unchecked", "rawtypes"})
private static void prepareGMTOffsetTimeZones() {
  for (String tzId : new String[]{"GMT-12:00", "GMT-11:00", "GMT-10:00", "GMT-09:00", "GMT-08:00", "GMT-07:00", "GMT-06:00",
                  "GMT-05:00", "GMT-04:00", "GMT-03:00", "GMT-02:00", "GMT-01:00", "GMT+01:00", "GMT+02:00",
                  "GMT+03:00", "GMT+04:00", "GMT+05:00", "GMT+06:00", "GMT+07:00", "GMT+08:00", "GMT+09:00",
                  "GMT+10:00", "GMT+11:00", "GMT+12:00"}) {
    TimeZone tz = TimeZone.getTimeZone(tzId);
    JSONObject json = new JSONObject();
    json.put(JsonTags.TIME_ZOME_DISPLAY_NAME, tz.getDisplayName(false, TimeZone.SHORT) + " (" + tzId + ")");
    json.put(JsonTags.TIME_ZONE_ID, tzId);
    GMTOffsetTimeZones.add(json);
  }
}
origin: rhuss/jolokia

private Object serializeArray(Object pArg) {
  JSONArray innerArray = new JSONArray();
  for (int i = 0; i < Array.getLength(pArg); i++ ) {
    innerArray.add(serializeArgumentToJson(Array.get(pArg, i)));
  }
  return innerArray;
}
org.json.simpleJSONArrayadd

Popular methods of JSONArray

  • <init>
  • size
  • get
  • toJSONString
    Convert a list to JSON text. The result is a JSON array. If this list is also a JSONAware, JSONAware
  • iterator
  • addAll
  • isEmpty
  • toString
  • toArray
  • writeJSONString
    Encode a list into JSON text and write it to out. If this list is also a JSONStreamAware or a JSONAw
  • contains
  • remove
  • contains,
  • remove,
  • set,
  • clear,
  • forEach,
  • getJsonObject,
  • listIterator,
  • subList

Popular in Java

  • Creating JSON documents from java classes using gson
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getApplicationContext (Context)
  • setScale (BigDecimal)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now