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

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

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

origin: shopizer-ecommerce/shopizer

@Override
public List<String> getSupportedCountries(MerchantStore store) throws ServiceException {
  
  List<String> supportedCountries = new ArrayList<String>();
  MerchantConfiguration configuration = merchantConfigurationService.getMerchantConfiguration(SUPPORTED_COUNTRIES, store);
  
  if(configuration!=null) {
    
    String countries = configuration.getValue();
    if(!StringUtils.isBlank(countries)) {
      Object objRegions=JSONValue.parse(countries); 
      JSONArray arrayRegions=(JSONArray)objRegions;
      @SuppressWarnings("rawtypes")
      Iterator i = arrayRegions.iterator();
      while(i.hasNext()) {
        supportedCountries.add((String)i.next());
      }
    }
    
  }
  
  return supportedCountries;
}

origin: DeemOpen/zkui

try {
  JSONArray acls = (JSONArray) ((JSONObject) new JSONParser().parse(jsonAcl)).get("acls");
  for (Iterator it = acls.iterator(); it.hasNext();) {
    JSONObject acl = (JSONObject) it.next();
    String scheme = ((String) acl.get("scheme")).trim();
origin: DeemOpen/zkui

if (authenticated) {
  JSONArray jsonRoleSet = (JSONArray) ((JSONObject) new JSONParser().parse(globalProps.getProperty("ldapRoleSet"))).get("users");
  for (Iterator it = jsonRoleSet.iterator(); it.hasNext();) {
    JSONObject jsonUser = (JSONObject) it.next();
    if (jsonUser.get("username") != null && jsonUser.get("username").equals("*")) {
for (Iterator it = jsonRoleSet.iterator(); it.hasNext();) {
  JSONObject jsonUser = (JSONObject) it.next();
  if (jsonUser.get("username").equals(username) && jsonUser.get("password").equals(password)) {
origin: shopizer-ecommerce/shopizer

JSONArray arrayRegions=(JSONArray)objRegions;
@SuppressWarnings("rawtypes")
Iterator i = arrayRegions.iterator();
while(i.hasNext()) {
  supportedCountries.add((String)i.next());
origin: shopizer-ecommerce/shopizer

Object objRegions=JSONValue.parse(regions); 
JSONArray arrayRegions=(JSONArray)objRegions;
Iterator i = arrayRegions.iterator();
while(i.hasNext()) {
  mod.getRegionsSet().add((String)i.next());
Iterator i = arrayConfigs.iterator();
while(i.hasNext()) {
origin: apache/metron

public HostFromJSONListAdapter(String jsonList) {
 JSONArray jsonArray = (JSONArray) JSONValue.parse(jsonList);
 Iterator jsonArrayIterator = jsonArray.iterator();
 while(jsonArrayIterator.hasNext()) {
  JSONObject jsonObject = (JSONObject) jsonArrayIterator.next();
  String host = (String) jsonObject.remove("ip");
  _known_hosts.put(host, jsonObject);
 }
}
origin: rackerlabs/blueflood

  @Test
  public void testBatchedMetricsSerialization() throws Exception {
    final BatchedMetricsJSONOutputSerializer serializer = new BatchedMetricsJSONOutputSerializer();

    final Map<Locator, MetricData> metrics = new HashMap<Locator, MetricData>();
    for (int i = 0; i < 2; i++) {
      final MetricData metricData = new MetricData(FakeMetricDataGenerator.generateFakeRollupPoints(), "unknown");

      metrics.put(Locator.createLocatorFromPathComponents(tenantId, String.valueOf(i)), metricData);
    }

    JSONObject jsonMetrics = serializer.transformRollupData(metrics, filterStats);

    Assert.assertTrue(jsonMetrics.get("metrics") != null);
    JSONArray jsonMetricsArray = (JSONArray) jsonMetrics.get("metrics");

    Iterator<JSONObject> metricsObjects = jsonMetricsArray.iterator();
    Assert.assertTrue(metricsObjects.hasNext());

    while (metricsObjects.hasNext()) {
      JSONObject singleMetricObject = metricsObjects.next();
      Assert.assertTrue(singleMetricObject.get("unit").equals("unknown"));
      Assert.assertTrue(singleMetricObject.get("type").equals("number"));
      JSONArray data = (JSONArray) singleMetricObject.get("data");
      Assert.assertTrue(data != null);
    }
  }
}
origin: apache/metron

@Test
public void testInitializeAdapter() throws Exception {
  Map<String, JSONObject> mapKnownHosts = new HashMap<>();
  HostFromPropertiesFileAdapter hfa = new HostFromPropertiesFileAdapter(mapKnownHosts);
  Assert.assertFalse(hfa.initializeAdapter(null));
  JSONArray jsonArray = (JSONArray) JSONValue.parse(expectedKnownHostsString);
  Iterator jsonArrayIterator = jsonArray.iterator();
  while(jsonArrayIterator.hasNext()) {
    JSONObject jsonObject = (JSONObject) jsonArrayIterator.next();
    String host = (String) jsonObject.remove("ip");
    mapKnownHosts.put(host, jsonObject);
  }
  hfa = new HostFromPropertiesFileAdapter(mapKnownHosts);
  Assert.assertTrue(hfa.initializeAdapter(null));
}
origin: apache/metron

@Test
public void testEnrich() throws Exception {
  Map<String, JSONObject> mapKnownHosts = new HashMap<>();
  JSONArray jsonArray = (JSONArray) JSONValue.parse(expectedKnownHostsString);
  Iterator jsonArrayIterator = jsonArray.iterator();
  while(jsonArrayIterator.hasNext()) {
    JSONObject jsonObject = (JSONObject) jsonArrayIterator.next();
    String host = (String) jsonObject.remove("ip");
    mapKnownHosts.put(host, jsonObject);
  }
  HostFromPropertiesFileAdapter hfa = new HostFromPropertiesFileAdapter(mapKnownHosts);
  JSONObject actualMessage = hfa.enrich(new CacheKey("dummy", ip, null));
  Assert.assertNotNull(actualMessage);
  Assert.assertEquals(expectedMessage, actualMessage);
  actualMessage = hfa.enrich(new CacheKey("dummy", ip1, null));
  JSONObject emptyJson = new JSONObject();
  Assert.assertEquals(emptyJson, actualMessage);
}
origin: com.hurence.logisland/logisland-common-processors-plugin

protected Set<String> getSchemaFields(String schema) throws FileNotFoundException, IOException, ParseException, URISyntaxException {
  Set<String> res = new HashSet<>();
  JSONParser parser = new JSONParser();
  JSONObject jsonObject = (JSONObject) parser.parse(new FileReader(this.getClass().getResource(schema).toURI().getPath()));
  JSONArray jsonArray = (JSONArray) jsonObject.get("fields");
  jsonArray.iterator().forEachRemaining(o -> res.add(((JSONObject) o).get("name").toString()));
  return res;
}
origin: yhegde/facebook-page-scraper

public List<Comment> getComments()
{
  List<Comment> tempComments = new ArrayList<Comment>();
  Iterator itr = comments.iterator();
  while (itr.hasNext())
  {
    JSONObject comment = (JSONObject) itr.next();
    tempComments.add(new Comment(comment, postId, commentId));
  }
  return tempComments;
}
origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.mdm.restconnector

private JSONArray getDeviceIdsFromDevices(JSONArray devices) {
  JSONArray deviceIdentifiers = new JSONArray();
  Iterator<JSONObject> iterator = devices.iterator();
  while (iterator.hasNext()) {
    JSONObject deviceObj = iterator.next();
    JSONObject obj = new JSONObject();
    obj.put(Constants.ID, deviceObj.get(Constants.DEVICE_IDENTIFIER).toString());
    obj.put(Constants.TYPE, deviceObj.get(Constants.TYPE).toString());
    deviceIdentifiers.add(obj);
  }
  return deviceIdentifiers;
}
origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.core

private Map<String, Scope> extractScopesFromJson(JSONObject scopesJson) {
  Map<String, Scope> scopeMap = new HashMap<>();
  if (scopesJson != null) {
    Iterator<?> scopesIterator = ((JSONArray) ((JSONObject) scopesJson
        .get(APIMgtConstants.SWAGGER_OBJECT_NAME_APIM)).get(APIMgtConstants.SWAGGER_X_WSO2_SCOPES))
        .iterator();
    while (scopesIterator.hasNext()) {
      Scope scope = new Gson().fromJson(((JSONObject) scopesIterator.next()).toJSONString(),
          Scope.class);
      scopeMap.put(scope.getName(), scope);
    }
  } else {
    if (log.isDebugEnabled()) {
      log.debug("Unable to extract scopes from provided json as it is null.");
    }
  }
  log.debug("Scopes of extracted from Swagger: {}", scopeMap);
  return scopeMap;
}
origin: wso2/carbon-apimgt

private Map<String, Scope> extractScopesFromJson(JSONObject scopesJson) {
  Map<String, Scope> scopeMap = new HashMap<>();
  if (scopesJson != null) {
    Iterator<?> scopesIterator = ((JSONArray) ((JSONObject) scopesJson
        .get(APIMgtConstants.SWAGGER_OBJECT_NAME_APIM)).get(APIMgtConstants.SWAGGER_X_WSO2_SCOPES))
        .iterator();
    while (scopesIterator.hasNext()) {
      Scope scope = new Gson().fromJson(((JSONObject) scopesIterator.next()).toJSONString(),
          Scope.class);
      scopeMap.put(scope.getName(), scope);
    }
  } else {
    if (log.isDebugEnabled()) {
      log.debug("Unable to extract scopes from provided json as it is null.");
    }
  }
  log.debug("Scopes of extracted from Swagger: {}", scopeMap);
  return scopeMap;
}
origin: com.adobe.ride/ride-model-util

/**
 * Method to return the model with only the required properties and their definitions
 * 
 * @param objModel model from which the required only properties are to be
 * @return JSONObject model representation with only the required properties and their definitions
 */
@SuppressWarnings("unchecked")
private JSONObject getRequiredOnlyDefs(JSONObject objModel) {
 JSONObject returnObjProps = new JSONObject();
 JSONObject allProps = (JSONObject) objModel.get("properties");
 JSONArray reqProps = (JSONArray) objModel.get("required");
 if (reqProps != null) {
  Iterator<String> i = reqProps.iterator();
  Set<String> keyset = allProps.keySet();
  while (i.hasNext()) {
   String req_property = i.next().toString();
   for (String s : keyset) {
    if (req_property.equals(s.toString())) {
     returnObjProps.put(s, allProps.get(s));
    }
   }
  }
 }
 return returnObjProps;
}
origin: BiglySoftware/BiglyBT

  public void toString( StringBuilder sb ){
    sb.append( "[" );

    Iterator<Object> iter=iterator();

    boolean	first = true;
    while(iter.hasNext()){
      if ( first ){
        first = false;
      }else{
        sb.append( "," );
      }
      Object value=iter.next();
      if(value instanceof String){
        sb.append( "\"" );
        JSONObject.escape(sb, (String)value);
        sb.append( "\"");
      }else if ( value instanceof JSONObject ){
        ((JSONObject)value).toString( sb );
      }else if ( value instanceof JSONArray ){
        ((JSONArray)value).toString( sb );
      }else{
        sb.append(String.valueOf(value));
      }
    }

    sb.append( "]" );
  }
}
origin: apache/hama

 @SuppressWarnings("unchecked")
 @Override
 public boolean parseVertex(LongWritable key, Text value,
   Vertex<Text, NullWritable, DoubleWritable> vertex) throws Exception {
  JSONArray jsonArray = (JSONArray) new JSONParser()
    .parse(value.toString());
  vertex.setVertexID(new Text(jsonArray.get(0).toString()));
  Iterator<JSONArray> iter = ((JSONArray) jsonArray.get(2)).iterator();
  while (iter.hasNext()) {
   JSONArray edge = iter.next();
   vertex.addEdge(new Edge<Text, NullWritable>(new Text(edge.get(0)
     .toString()), null));
  }
  return true;
 }
}
origin: apache/hama

 @SuppressWarnings("unchecked")
 @Override
 public boolean parseVertex(LongWritable key, Text value,
   Vertex<Text, NullWritable, DoubleWritable> vertex) throws Exception {
  JSONArray jsonArray = (JSONArray) new JSONParser()
    .parse(value.toString());
  vertex.setVertexID(new Text(jsonArray.get(0).toString()));
  Iterator<JSONArray> iter = ((JSONArray) jsonArray.get(2)).iterator();
  while (iter.hasNext()) {
   JSONArray edge = (JSONArray) iter.next();
   vertex.addEdge(new Edge<Text, NullWritable>(new Text(edge.get(0)
     .toString()), null));
  }
  return true;
 }
}
origin: aerospike/aerospike-loader

private static boolean getUpdateMappingColumnDefs(JSONObject jobj, List<MappingDefinition> mappingDefs) throws Exception {
  Object obj = null;
  JSONArray mappings;
  if ((obj = getFromJsonObject(jobj, Constants.MAPPINGS)) != null) {
    mappings = (JSONArray) obj;
    Iterator<?> it = mappings.iterator();
    while (it.hasNext()) {
      JSONObject mappingObj = (JSONObject) it.next();
      MappingDefinition md = getMappingDef(mappingObj);
      if (md != null) {
        mappingDefs.add(md);
      } else {
        log.error("Error in parsing mappingdef: " + mappingObj.toString());
        return false;
      }
    }
  }
  return true;
}

origin: BiglySoftware/BiglyBT

public String toString(){
  ItemList list=new ItemList();
  Iterator<Object> iter=iterator();
  while(iter.hasNext()){
    Object value=iter.next();
    if(value instanceof String){
      list.add("\""+JSONObject.escape((String)value)+"\"");
    }
    else
      list.add(String.valueOf(value));
  }
  return "["+list.toString()+"]";
}
org.json.simpleJSONArrayiterator

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
  • addAll
  • isEmpty
  • toString
  • toArray
  • writeJSONString
  • contains
  • remove
  • contains,
  • remove,
  • set,
  • clear,
  • forEach,
  • getJsonObject,
  • listIterator,
  • subList

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSharedPreferences (Context)
  • setRequestProperty (URLConnection)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • ImageIO (javax.imageio)
  • JPanel (javax.swing)
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • 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