Delivers the correct JSON Object for the Bounds

@param bounds
@throws org.json.JSONException
542536
private static JSONObject parseBounds(Bounds bounds) throws JSONException {
        if (bounds != null) {
            JSONObject boundsObject = new JSONObject();
            JSONObject lowerRight = new JSONObject();
            JSONObject upperLeft = new JSONObject();

            lowerRight.put("x",
                           bounds.getLowerRight().getX().doubleValue());
            lowerRight.put("y",
                           bounds.getLowerRight().getY().doubleValue());

            upperLeft.put("x",
                          bounds.getUpperLeft().getX().doubleValue());
            upperLeft.put("y",
                          bounds.getUpperLeft().getY().doubleValue());

            boundsObject.put("lowerRight",
                             lowerRight);
            boundsObject.put("upperLeft",
                             upperLeft);

            return boundsObject;
        }

        return new JSONObject();
    }
579385
public static JSONObject getJSONObject(HttpPost request, Integer method, HashMap<String, String> params) throws JSONException {
        switch (method) {
        case METHOD_PUT:
        case METHOD_DELETE:
        case METHOD_POST:
            return doPostRequest(request, params);
        default:
            throw new RuntimeException("Wrong http method requested");
        }
    }
1010423
private static FieldDefinition fillFieldDefinitionData(final JSONObject fieldDefinitionObject) throws JSONException {
        final FieldDefinition ret = new FieldDefinition();
        ret.setName(fieldDefinitionObject.getString(NAME));
        ret.setDescription(fieldDefinitionObject.optString(DESCRIPTION));
        ret.setType(fieldDefinitionObject.getString(TYPE));
        ret.setNullable(fieldDefinitionObject.optBoolean(NULLABLE));
        ret.setLength(fieldDefinitionObject.optInt(LENGTH));
        ret.setIsKey(fieldDefinitionObject.optBoolean(ISKEY));
        if (defaultKeyName.equals(ret.getName())) {
            ret.setIsKey(true);
        }

        return ret;
    }
257360
function (bounds) {
		return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY;
	}
468436
@Override
    public BoundingBox deserialize(final JsonElement json, final Type typeOfT,
            final JsonDeserializationContext context) {

        final BoundingBox bbox;

        if (json.isJsonArray()) {
            final JsonArray bboxJsonArray = json.getAsJsonArray();
            bbox = new BoundingBox();
            bbox.setSouth(bboxJsonArray.get(0).getAsDouble());
            bbox.setNorth(bboxJsonArray.get(1).getAsDouble());
            bbox.setWest(bboxJsonArray.get(2).getAsDouble());
            bbox.setEast(bboxJsonArray.get(3).getAsDouble());
        } else {
            throw new JsonParseException("Unexpected data: " + json.toString());
        }

        return bbox;
    }
424435
private static <T> T jsonDecode(String responseContent, TypeReference<T> valueTypeRef) throws IOException {

      ObjectMapper mapper = new ObjectMapper();
      
      try {
         return mapper.<T>readValue(responseContent, valueTypeRef);
      } catch (JsonGenerationException e) {
         logger.severe("unable decode");
         throw new IOException(e);
      } catch (JsonMappingException e) {
         logger.severe("unable decode");
         throw new IOException(e.getMessage());
      }
   }
576586
public void loadFromJSONPlan(JSONObject jobj, Database db)  throws JSONException {
        if (jobj.has(Members.PLAN_NODES_LISTS)) {
            JSONArray jplanNodesArray = jobj.getJSONArray(Members.PLAN_NODES_LISTS);
            for (int i = 0; i < jplanNodesArray.length(); ++i) {
                JSONObject jplanNodesObj = jplanNodesArray.getJSONObject(i);
                JSONArray jplanNodes = jplanNodesObj.getJSONArray(Members.PLAN_NODES);
                int stmtId = jplanNodesObj.getInt(Members.STATEMENT_ID);
                loadPlanNodesFromJSONArrays(stmtId, jplanNodes, db);
            }
        }
        else {
            // There is only one statement in the plan. Its id is set to 0 by default
            int stmtId = 0;
            JSONArray jplanNodes = jobj.getJSONArray(Members.PLAN_NODES);
            loadPlanNodesFromJSONArrays(stmtId, jplanNodes, db);
        }

        // Connect the parent and child statements
        for (List<AbstractPlanNode> nextPlanNodes : m_planNodesListMap.values()) {
            for (AbstractPlanNode node : nextPlanNodes) {
                connectNodesIfNecessary(node);
            }
        }
    }
1017801
public void loadFromJson(final Properties props, final Reader rd) throws IOException {
		try {
			((PrefixedProperties) props).loadFromJSON(rd);
		} catch (final NoSuchMethodError err) {
			throw new IOException(
					"Cannot load properties JSON file - not using PrefixedProperties: " + err.getMessage());
		}
	}
281589
function JSONExpander() {
  const self = this;
  self.process = ({ output }) => JSON.stringify(JSON.parse(output), null, 2);
}
487368
private void loadJsonResource(JSONObject json, Properties properties, Object name)
                                throws JSONException {
    Iterator<?> keys = json.keys();
    while (keys.hasNext()) {
      Object obj = keys.next();
      if (!(obj instanceof String)) {
        LOG.warn("Object not instance of string : " + obj + " skipping");
        continue;
      }
      String key = (String) obj;
      // can't have . in thrift fields so we represent . with _
      String keyUnderscoresToDots = key.replace("_", ".");  
      // actual _ are represented as __ in thrift schema
      keyUnderscoresToDots = keyUnderscoresToDots.replace("..", "_");
      if (!json.isNull(key)) {
        Object value = json.get(key);
        String stringVal = "";
        if (value instanceof String) {
          stringVal = (String)value;
        } else if (value instanceof Integer) {
            stringVal = new Integer((Integer)value).toString();
        } else if (value instanceof Long) {
            stringVal = new Long((Long)value).toString();
        } else if (value instanceof Double) {
            stringVal = new Double((Double)value).toString();
        } else if (value instanceof Boolean) {
            stringVal = new Boolean((Boolean)value).toString();
        } else if (value instanceof JSONObject) {
            loadJsonResource((JSONObject)value, properties, name);
            continue;
        } else {
            LOG.warn("unsupported value in json object: " + value);
        }
        if (!finalParameters.contains(keyUnderscoresToDots)) {
          properties.setProperty(keyUnderscoresToDots, stringVal);
          updatingResource.put(keyUnderscoresToDots, name.toString());
    	} else {
    	    LOG.warn(name+":a attempt to override final parameter: "+
                     keyUnderscoresToDots+";  Ignoring.");
    	}
      } 
    }
  }
839519
public JsonObject sendQuery(FutureAPIResponse response)
      throws ExecutionException, InterruptedException, IOException {
    int status = response.get().getStatus();
    String message = response.get().getMessage();

    if (status != HTTP_OK) {
      throw new IOException(status + " " + message);
    }
    return ((JsonObject) parser.parse(message));
  }
1221369
private void parseFeatures(JsonParser jp) throws IOException, SQLException {
        jp.nextToken(); // FIELD_NAME features
        // Passes all the properties until "Feature" object is found
        while(!jp.getText().equalsIgnoreCase(GeoJsonField.FEATURES) &&
                !jp.getText().equalsIgnoreCase(GeoJsonField.CRS)){
            jp.nextToken();
            if(jp.getCurrentToken().equals(JsonToken.START_ARRAY) || jp.getCurrentToken().equals(JsonToken.START_OBJECT)){
                jp.skipChildren();
            }
            jp.nextToken();
        }
        String firstParam = jp.getText();
        if(firstParam.equalsIgnoreCase(GeoJsonField.CRS)){
            firstParam = skipCRS(jp);
        }
        if (firstParam.equalsIgnoreCase(GeoJsonField.FEATURES)) {
            jp.nextToken(); // START_ARRAY [
            JsonToken token = jp.nextToken(); // START_OBJECT {
            long batchSize = 0;
            while (token != JsonToken.END_ARRAY) {
                jp.nextToken(); // FIELD_NAME type
                jp.nextToken(); // VALUE_STRING Feature
                String geomType = jp.getText();
                if (geomType.equalsIgnoreCase(GeoJsonField.FEATURE)) {         
                    if (progress.isCanceled()) {
                        throw new SQLException("Canceled by user");
                    }
                    Object[] values = parseFeature(jp);
                    
                    for (int i = 0; i < values.length; i++) {
                        preparedStatement.setObject(i+1, values[i]);                        
                    }
                    
                    preparedStatement.addBatch();
                    batchSize++;
                    if (batchSize >= BATCH_MAX_SIZE) {
                        preparedStatement.executeBatch();
                        preparedStatement.clearBatch();
                        batchSize = 0;
                    }
                    
                    token = jp.nextToken(); //START_OBJECT new feature                    
                    featureCounter++;
                    if (nodeCountProgress++ % readFileSizeEachNode == 0) {
                        // Update Progress
                        try {
                            progress.setStep((int) (((double) fc.position() / fileSize) * 100));
                        } catch (IOException ex) {
                            // Ignore
                        }
                    }
                    if (batchSize > 0) {
                        preparedStatement.executeBatch();
                    }
                } else {
                    throw new SQLException("Malformed GeoJSON file. Expected 'Feature', found '" + geomType + "'");
                }
            }
            //LOOP END_ARRAY ]
            log.info(featureCounter+ " geojson features have been imported.");
        } else {
            throw new SQLException("Malformed GeoJSON file. Expected 'features', found '" + firstParam + "'");
        }
    }
1303519
private void collectStaticGettersResults(@NonNull Class<?> someClass, @NonNull JSONObject container) throws JSONException {
        final Method[] methods = someClass.getMethods();
        for (final Method method : methods) {
            if (method.getParameterTypes().length == 0
                    && (method.getName().startsWith("get") || method.getName().startsWith("is"))
                    && !"getClass".equals(method.getName())) {
                try {
                    container.put(method.getName(), method.invoke(null, (Object[]) null));
                } catch (@NonNull IllegalArgumentException ignored) {
                    // NOOP
                } catch (@NonNull InvocationTargetException ignored) {
                    // NOOP
                } catch (@NonNull IllegalAccessException ignored) {
                    // NOOP
                }
            }
        }
    }
1250407
public static ScanResult fromJSON(final String json) {
        final Matcher matcher = Pattern.compile("\\{[\\n\\r ]*\"format\"[ ]?:[ ]?\"([^\"]+)\"").matcher(json);
        if (!matcher.find()) {
            throw new IllegalArgumentException("JSON is not in correct format");
        }
        if (!CURRENT_SERIALIZATION_FORMAT.equals(matcher.group(1))) {
            throw new IllegalArgumentException(
                    "JSON was serialized in a different format from the format used by the current version of "
                            + "ClassGraph -- please serialize and deserialize your ScanResult using "
                            + "the same version of ClassGraph");
        }

        // Deserialize the JSON
        final SerializationFormat deserialized = JSONDeserializer.deserializeObject(SerializationFormat.class,
                json);
        if (!deserialized.format.equals(CURRENT_SERIALIZATION_FORMAT)) {
            // Probably the deserialization failed before now anyway, if fields have changed, etc.
            throw new IllegalArgumentException("JSON was serialized by newer version of ClassGraph");
        }

        // Perform a new "scan" with performScan set to false, which resolves all the ClasspathElement objects
        // and scans classpath element paths (needed for classloading), but does not scan the actual classfiles
        final ClassGraph classGraph = new ClassGraph();
        classGraph.scanSpec = deserialized.scanSpec;
        classGraph.scanSpec.performScan = false;
        if (classGraph.scanSpec.overrideClasspath == null) {
            // Use the same classpath as before, if classpath was not overridden
            classGraph.overrideClasspath(deserialized.classpath);
        }
        final ScanResult scanResult = classGraph.scan();
        scanResult.rawClasspathEltOrderStrs = deserialized.classpath;
        scanResult.scanSpec.performScan = true;

        // Set the fields related to ClassInfo in the new ScanResult, based on the deserialized JSON 
        scanResult.scanSpec = deserialized.scanSpec;
        scanResult.classNameToClassInfo = new HashMap<>();
        if (deserialized.classInfo != null) {
            for (final ClassInfo ci : deserialized.classInfo) {
                scanResult.classNameToClassInfo.put(ci.getName(), ci);
                ci.setScanResult(scanResult);
            }
        }
        scanResult.moduleNameToModuleInfo = new HashMap<>();
        if (deserialized.moduleInfo != null) {
            for (final ModuleInfo mi : deserialized.moduleInfo) {
                scanResult.moduleNameToModuleInfo.put(mi.getName(), mi);
            }
        }
        scanResult.packageNameToPackageInfo = new HashMap<>();
        if (deserialized.packageInfo != null) {
            for (final PackageInfo pi : deserialized.packageInfo) {
                scanResult.packageNameToPackageInfo.put(pi.getName(), pi);
            }
        }

        // Index Resource and ClassInfo objects 
        scanResult.indexResourcesAndClassInfo();

        scanResult.isObtainedFromDeserialization = true;
        return scanResult;
    }
1082475
public JSONObject getJSONObject(int index) throws JSONException {
		Object object = get(index);
		if (object instanceof JSONObject) {
			return (JSONObject) object;
		}
		else {
			throw JSON.typeMismatch(index, object, "JSONObject");
		}
	}
1068726
public JsonObject sendQuery(Map<String, Object> query)
      throws ExecutionException, InterruptedException, IOException {
    return sendQuery(sendQueryAsFuture(query));
  }
146030
public static void handleResult(String json) {

        JSONObject jsonObj = JSONParser.parseLenient(json).isObject();
        JSONArray results = jsonObj.get(CmsDataViewConstants.KEY_RESULT).isArray();
        String accessorId = jsonObj.get(CmsDataViewConstants.ACCESSOR).isString().stringValue();
        CmsDataViewValueAccessor accessor = accessors.get(accessorId);
        List<CmsDataViewValue> values = Lists.newArrayList();
        for (int i = 0; i < results.size(); i++) {
            JSONObject singleResult = results.get(i).isObject();
            String id = singleResult.get(CmsDataViewConstants.FIELD_ID).isString().stringValue();
            String title = singleResult.get(CmsDataViewConstants.FIELD_TITLE).isString().stringValue();
            String description = singleResult.get(CmsDataViewConstants.FIELD_DESCRIPTION).isString().stringValue();
            String data = singleResult.get(CmsDataViewConstants.FIELD_DATA).isString().stringValue();
            CmsDataViewValue value = new CmsDataViewValue(id, title, description, data);
            values.add(value);
        }
        accessor.replaceValue(values);
    }