Tabnine Logo
JSONArray.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.json.simple.JSONArray
constructor

Best Java code snippets using org.json.simple.JSONArray.<init> (Showing top 20 results out of 1,323)

Refine searchRefine arrow

  • JSONArray.add
  • 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

@SuppressWarnings( "unchecked" )
private void outPutRow( Object[] rowData ) throws KettleStepException {
 // We can now output an object
 data.jg = new JSONObject();
 data.jg.put( data.realBlocName, data.ja );
 String value = data.jg.toJSONString();
 if ( data.outputValue && data.outputRowMeta != null ) {
  Object[] outputRowData = RowDataUtil.addValueData( rowData, data.inputRowMetaSize, value );
  incrementLinesOutput();
  putRow( data.outputRowMeta, outputRowData );
 }
 if ( data.writeToFile && !data.ja.isEmpty() ) {
  // Open a file
  if ( !openNewFile() ) {
   throw new KettleStepException( BaseMessages.getString(
    PKG, "JsonOutput.Error.OpenNewFile", buildFilename() ) );
  }
  // Write data to file
  try {
   data.writer.write( value );
  } catch ( Exception e ) {
   throw new KettleStepException( BaseMessages.getString( PKG, "JsonOutput.Error.Writing" ), e );
  }
  // Close file
  closeFile();
 }
 // Data are safe
 data.rowsAreSafe = true;
 data.ja = new JSONArray();
}
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: 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: ethereum/ethereumj

JSONObject execJSON = (JSONObject) testCaseJSONObj.get("exec");
JSONObject preJSON = (JSONObject) testCaseJSONObj.get("pre");
JSONObject postJSON = new JSONObject();
if (testCaseJSONObj.containsKey("post")) {
  postJSON = (JSONObject) testCaseJSONObj.get("post");
JSONArray callCreates = new JSONArray();
if (testCaseJSONObj.containsKey("callcreates"))
  callCreates = (JSONArray) testCaseJSONObj.get("callcreates");
Object logsJSON = new JSONArray();
if (testCaseJSONObj.containsKey("logs"))
  logsJSON = testCaseJSONObj.get("logs");
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: 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: Exslims/MercuryTrade

private void createEmptyFile() {
  try {
    FileWriter fileWriter = new FileWriter(HISTORY_FILE);
    JSONObject root = new JSONObject();
    root.put("messages", new JSONArray());
    fileWriter.write(root.toJSONString());
    fileWriter.flush();
    fileWriter.close();
  } catch (IOException e) {
    logger.error("Error during creating history file: ", e);
  }
}
origin: apache/chukwa

public UserBean() {
 views = new JSONArray();
 properties = new JSONObject();
}

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: 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: mcmonkeyprojects/Sentinel

/**
 * Gets the plugin specific data.
 * This method is called using Reflection.
 *
 * @return The plugin specific data.
 */
public JSONObject getPluginData() {
  JSONObject data = new JSONObject();
  String pluginName = plugin.getDescription().getName();
  String pluginVersion = plugin.getDescription().getVersion();
  data.put("pluginName", pluginName); // Append the name of the plugin
  data.put("pluginVersion", pluginVersion); // Append the version of the plugin
  JSONArray customCharts = new JSONArray();
  data.put("customCharts", customCharts);
  return data;
}
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: 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: GoMint/GoMint

@Override
public JSONObject toJSON() {
  JSONObject obj = super.toJSON();
  obj.put( "type", "step_slider" );
  JSONArray jsonSteps = new JSONArray();
  for ( String step : this.steps ) {
    jsonSteps.add( step );
  }
  obj.put( "steps", jsonSteps );
  obj.put( "default", this.defaultStep );
  return obj;
}
origin: Bastian/bStats-Metrics

/**
 * Gets the plugin specific data.
 * This method is called using Reflection.
 *
 * @return The plugin specific data.
 */
public JSONObject getPluginData() {
  JSONObject data = new JSONObject();
  String pluginName = plugin.getDescription().getName();
  String pluginVersion = plugin.getDescription().getVersion();
  data.put("pluginName", pluginName); // Append the name of the plugin
  data.put("pluginVersion", pluginVersion); // Append the version of the plugin
  JSONArray customCharts = new JSONArray();
  data.put("customCharts", customCharts);
  return data;
}
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);
org.json.simpleJSONArray<init>

Javadoc

Constructs an empty JSONArray.

Popular methods of JSONArray

  • add
  • 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

  • Running tasks concurrently on multiple threads
  • scheduleAtFixedRate (ScheduledExecutorService)
  • findViewById (Activity)
  • runOnUiThread (Activity)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • JOptionPane (javax.swing)
  • Best plugins for Eclipse
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