Parses the given JSON data as a hash.
@param json JSON-formatted data
@return {@link JsonHash}
@throws IOException
@throws JsonFormatException
@author vvakame
481118
public static JsonHash fromString(String json) throws IOException, JsonFormatException {
		JsonPullParser parser = JsonPullParser.newParser(json);
		return fromParser(parser);
	}
1008596
public String format(String json) {
        String result = null;
        if (json != null){
            if (json.startsWith("{")) {
                result = new JSONObject(json).toString(4);
            } else if (json.startsWith("[")) {
                JSONObject jsonObject = new JSONObject("{'a': " + json + "}");
                org.json.JSONArray array = (org.json.JSONArray) jsonObject.get("a");
                result = array.toString(4);
            }
        }
        return result;
    }
1236463
@JsonCreator
    public static GeoDistance parse(String json) {
        try {
            String unit = null;
            for (GeoDistanceUnit geoDistanceUnit : GeoDistanceUnit.values()) {
                for (String name : geoDistanceUnit.getNames()) {
                    if (json.endsWith(name) && (unit == null || unit.length() < name.length())) {
                        unit = name;
                    }
                }
            }
            if (unit != null) {
                double value = Double.parseDouble(json.substring(0, json.indexOf(unit)));
                return new GeoDistance(value, GeoDistanceUnit.create(unit));
            }
            double value = Double.parseDouble(json);
            return new GeoDistance(value, GeoDistanceUnit.METRES);
        } catch (Exception e) {
            throw new IndexException(e, "Unparseable distance: {}", json);
        }
    }
588776
public static <E> E parse(String jsonString, Class<E> jsonObjectClass) throws IOException {
        return mapperFor(jsonObjectClass).parse(jsonString);
    }
733647
public static JWEObject deserialize(String json) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.readValue(json, JWEObject.class);
    }
75173
static function json_parse($json = '', $assoc = false, $depth = 512)
    {

        $parsed = \json_decode($json, $assoc, $depth);

        //if (JSON_ERROR_NONE !== json_last_error()) {
        //    throw new \RuntimeException('JSON Error: Unable to parse into JSON: ' . json_last_error());
        //}

        $error = json_last_error();

        switch ($error) {
            case JSON_ERROR_NONE:
                break;
            case JSON_ERROR_DEPTH:
                throw new InvalidArgumentException('JSON Error: Maximum stack depth exceeded');
                break;
            case JSON_ERROR_CTRL_CHAR:
                throw new InvalidArgumentException('JSON Error: Unexpected control character found');
                break;
            case JSON_ERROR_SYNTAX:
                throw new InvalidArgumentException('JSON Error: Syntax error, malformed JSON');
                break;
            default:
                throw new InvalidArgumentException('JSON Error: Unknown error');
                break;
        }

        // This is a courtesy by PHP JSON parser to parse "null" into null, but this is an error situation
        if (empty($parsed)) {
            throw new InvalidArgumentException('JSON Error: Result is empty after parsing');
        }

        return $parsed;

    }
1195191
public static TaskRouting fromJson(String json) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.readValue(json, TaskRouting.class);
    }
886711
public static Properties parseJSON(String json) {
    try {
      return utilsImpl.parseJSON(json);
    } catch (Exception e) {
      if (!GWT.isProdMode()) {
        System.err.println("Error while parsing json: " + e.getMessage() + ".\n" + json);
      }
      return Properties.create();
    }
  }
1182522
static boolean hasHits(@Nullable JSONObject jsonObject) {
        if (jsonObject == null) {
            return false;
        }

        JSONArray resultHits = jsonObject.optJSONArray("hits");
        if (resultHits == null) {
            return false;
        }

        for (int i = 0; i < resultHits.length(); ++i) {
            JSONObject hit = resultHits.optJSONObject(i);
            if (hit != null) {
                return true;
            }
        }
        return false;
    }
588255
public static TransformProcess fromJson(String json) {
        try {
            return JsonMappers.getMapper().readValue(json, TransformProcess.class);
        } catch (IOException e) {
            //TODO proper exception message
            throw new RuntimeException(e);
        }
    }
35358
@SuppressWarnings("unchecked")
	public static <K,V> Map<K,V> jsonToMap(String json){
		return FastJsonKit.parse(json, HashMap.class);
	}
1132630
protected function parse_json( $json ) {

		$data = json_decode( $json, true );

		if ( ! is_array( $data ) ) {
			$data = array();
		}

		return $data;
	}
1119611
private static Map<String, Map<String, String>> getStatsMap(String json)
      throws IOException {
    if (json == null || json.isEmpty()) {
      return new HashMap<String, Map<String, String>>();
    }
    TypeReference<Map<String, Map<String, String>>> type = new TypeReference<Map<String, Map<String, String>>>() {
    };
    return mapper.readValue(json, type);
  }
1338940
private void parseJSON(JsonObject jsonObject) {
        for (JsonObject.Member member : jsonObject) {
            JsonValue value = member.getValue();
            if (value.isNull()) {
                continue;
            }

            try {
                String memberName = member.getName();
                if (memberName.equals("id")) {
                    this.versionID = value.asString();
                } else if (memberName.equals("sha1")) {
                    this.sha1 = value.asString();
                } else if (memberName.equals("name")) {
                    this.name = value.asString();
                } else if (memberName.equals("size")) {
                    this.size = Double.valueOf(value.toString()).longValue();
                } else if (memberName.equals("created_at")) {
                    this.createdAt = BoxDateFormat.parse(value.asString());
                } else if (memberName.equals("modified_at")) {
                    this.modifiedAt = BoxDateFormat.parse(value.asString());
                } else if (memberName.equals("trashed_at")) {
                    this.trashedAt = BoxDateFormat.parse(value.asString());
                } else if (memberName.equals("modified_by")) {
                    JsonObject userJSON = value.asObject();
                    String userID = userJSON.get("id").asString();
                    BoxUser user = new BoxUser(getAPI(), userID);
                    this.modifiedBy = user.new Info(userJSON);
                }
            } catch (ParseException e) {
                assert false : "A ParseException indicates a bug in the SDK.";
            }
        }
    }
479934
def load_json!(json)
      return true if json == ""
      loaded_json = JSON.load(json)
      if loaded_json.is_a? Hash
        env.merge!(loaded_json)
        return true
      end
      false
    rescue JSON::ParserError
      return false
    end
363369
@SuppressWarnings("unchecked")
    public static Map<String,Object> decodeAsMap(String json) {
        return decode(json, HashMap.class);
    }
75672
public static Map<String, String> parse2Map(String json) {

        Type stringStringMap = new TypeToken<Map<String, String>>() {
        }.getType();

        Gson gson = new Gson();
        Map<String, String> map = gson.fromJson(json, stringStringMap);

        return map;
    }