Codota Logo
JSONArray.add
Code IndexAdd Codota 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>
  • 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: 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>
    Constructs a JSONArray containing the elements of the specified collection, in the order they are re
  • size
  • get
  • toJSONString
  • iterator
  • addAll
  • 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