Parse representations from a file object response.
@param jsonObject representations json object in get response for /files/file-id?fields=representations
@return list of representations
494544
public static List<Representation> parseRepresentations(JsonObject jsonObject) {
        List<Representation> representations = new ArrayList<Representation>();
        for (JsonValue representationJson : jsonObject.get("entries").asArray()) {
            Representation representation = new Representation(representationJson.asObject());
            representations.add(representation);
        }
        return representations;
    }
372537
public static List<DomesticResult> parseList(JsonNode json) {
        List<DomesticResult> results = new ArrayList<DomesticResult>();

        for (int i = 1; i <= MAX_RESULTS; i++) {
            String itemFieldName = String.format("g%d", i);

            if (json.has(itemFieldName)) {
                results.add(parseItem(json.get(itemFieldName)));
            } else {
                break;
            }
        }

        return results;
    }
11184
private void loadEntireJsonObject(JSONObject json) throws JSONException {
    Iterator<?> it = json.keys();
    while (it.hasNext()) {
      // This key is something like core-site.xml or hdfs-site.xml
      Object obj = it.next();
      if (!(obj instanceof String)) {
        LOG.warn("Object not instance of string : " + obj + " skipping");
        continue;
      }
      String key = (String) obj;
      JSONObject partition = json.getJSONObject(key);
      loadJsonResource(partition, properties, key);
    }
  }
712546
public static Map<String, Object> jsonObjectToMap(JSONObject jsonObj)
    {
        Map<String, Object> map = new Hashtable<String, Object>();
        
        Iterator<?> iterator = jsonObj.keys();
        while (iterator.hasNext())
        {
            try {
                String key = (String)iterator.next();
                String value = jsonObj.getString(key);  // TODO what if this is a JSONObject?
                map.put(key, value);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        return map;
    }
1041267
public static Map<String, Map<String, Metadata>> parseAndPopulateMetadataMap(JsonObject jsonObject) {
        Map<String, Map<String, Metadata>> metadataMap = new HashMap<String, Map<String, Metadata>>();
        //Parse all templates
        for (JsonObject.Member templateMember : jsonObject) {
            if (templateMember.getValue().isNull()) {
                continue;
            } else {
                String templateName = templateMember.getName();
                Map<String, Metadata> scopeMap = metadataMap.get(templateName);
                //If templateName doesn't yet exist then create an entry with empty scope map
                if (scopeMap == null) {
                    scopeMap = new HashMap<String, Metadata>();
                    metadataMap.put(templateName, scopeMap);
                }
                //Parse all scopes in a template
                for (JsonObject.Member scopeMember : templateMember.getValue().asObject()) {
                    String scope = scopeMember.getName();
                    Metadata metadataObject = new Metadata(scopeMember.getValue().asObject());
                    scopeMap.put(scope, metadataObject);
                }
            }

        }
        return metadataMap;
    }
1106913
private JSONObject readObject() throws JSONException {
		JSONObject result = new JSONObject();

		/* Peek to see if this is the empty object. */
		int first = nextCleanInternal();
		if (first == '}') {
			return result;
		}
		else if (first != -1) {
			this.pos--;
		}

		while (true) {
			Object name = nextValue();
			if (!(name instanceof String)) {
				if (name == null) {
					throw syntaxError("Names cannot be null");
				}
				else {
					throw syntaxError("Names must be strings, but " + name
							+ " is of type " + name.getClass().getName());
				}
			}

			/*
			 * Expect the name/value separator to be either a colon ':', an equals sign
			 * '=', or an arrow "=>". The last two are bogus but we include them because
			 * that's what the original implementation did.
			 */
			int separator = nextCleanInternal();
			if (separator != ':' && separator != '=') {
				throw syntaxError("Expected ':' after " + name);
			}
			if (this.pos < this.in.length() && this.in.charAt(this.pos) == '>') {
				this.pos++;
			}

			result.put((String) name, nextValue());

			switch (nextCleanInternal()) {
			case '}':
				return result;
			case ';':
			case ',':
				continue;
			default:
				throw syntaxError("Unterminated object");
			}
		}
	}
557855
protected Object readResponse(Type returnType, JsonNode jsonObject) throws Throwable {
		return readResponse(returnType, jsonObject, null);
	}
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();
    }
1151776
private static JSONObject parseRequestJSONObject(final HttpServletRequest request, final HttpServletResponse response) {
        response.setContentType("application/json");

        try {
            BufferedReader reader;
            try {
                reader = request.getReader();
            } catch (final IllegalStateException illegalStateException) {
                reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
            }

            String tmp = IOUtils.toString(reader);
            if (StringUtils.isBlank(tmp)) {
                tmp = "{}";
            } else {
                if (StringUtils.startsWithIgnoreCase(tmp, "%7B%22" /* {" */)) {
                    tmp = URLs.decode(tmp);
                }
            }

            return new JSONObject(tmp);
        } catch (final Exception e) {
            LOGGER.log(Level.ERROR, "Parses request JSON object failed [" + e.getMessage() + "], returns an empty json object");

            return new JSONObject();
        }
    }
479438
private static JSONObject extractObject(HttpResponse resp) throws IOException, JSONException {
        logger.entering(resp);
        BufferedReader rd = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
        StringBuilder s = new StringBuilder();
        String line;
        while ((line = rd.readLine()) != null) {
            s.append(line);
        }
        rd.close();
        JSONObject objToReturn = new JSONObject(s.toString());
        logger.exiting(objToReturn);
        return objToReturn;
    }
385292
public static KeyFile parse(byte[] serialized) {
		try (InputStream in = new ByteArrayInputStream(serialized); //
				Reader reader = new InputStreamReader(in, UTF_8); //
				JsonReader jsonReader = GSON.newJsonReader(reader)) {
			JsonObject jsonObj = new JsonParser().parse(jsonReader).getAsJsonObject();
			KeyFile result = GSON.fromJson(jsonObj, GenericKeyFile.class);
			result.jsonObj = jsonObj;
			return result;
		} catch (IOException | JsonParseException e) {
			throw new IllegalArgumentException("Unable to parse key file.", e);
		}
	}
281595
public Object deserialize(String jsonObject) {
		if (LOGGER.isDebugEnabled()) {
			LOGGER.debug("Deserializing Json object");
		}
		XStream xstream = new XStream(new JettisonMappedXmlDriver());
		Object obj = xstream.fromXML(jsonObject);
		if (LOGGER.isDebugEnabled()) {
			LOGGER.debug("Object deserialized");
		}
		return obj;
	}
1112145
private function getJsonObject($line, $splitKeys, array $jsonObject = []): array
    {
        $values = $this->parseCsv($line);
        for ($valueIndex = 0, $count = \count($values); $valueIndex < $count; $valueIndex++) {
            if ($values[$valueIndex] === '') {
                continue;
            }
            $this->setJsonValue($splitKeys[$valueIndex], 0, $jsonObject, $values[$valueIndex]);
        }
        return $jsonObject;
    }
151748
def _fromJSON(cls, jsonobject):
        
        newInstance = cls(jsonobject[0], jsonobject[1])
        for arrayType, jsonEntry in viewitems(jsonobject[2]):
            arrayEntry = {'dataProcessingRef': jsonEntry['dataProcessingRef'],
                          'params': [tuple(_) for _ in jsonEntry['params']]
                          }
            newInstance.arrayInfo[arrayType] = arrayEntry

        return newInstance
107658
public static JsonArray getArray(JsonObject object, String field) {
        final JsonValue value = object.get(field);
        throwExceptionIfNull(value, field);
        return value.asArray();
    }
487997
private String parseResponseAlbumIds(String json) {
    StringJoiner sj = new StringJoiner(",");
    try {
      JsonNode jsonNode = this.objectMapper.readTree(json);
      for (JsonNode node : jsonNode.get("albums").get("items")) {
        sj.add(node.get("id").asText());
      }
    } catch (IOException e) {
      throw new RuntimeException("Failed to parse JSON", e);
    }
    return sj.toString();
  }
1027700
private List<String> objectKeys(JsonObject obj) {
    List<String> keys = new ArrayList<>();
    for (Map.Entry<String, JsonElement> entry : obj.entrySet()) {
      keys.add(entry.getKey());
    }
    return keys;
  }