Constructs a Location object from rawJSON string.

@param rawJSON raw JSON form as String
@return Location
@throws TwitterException when provided string is not a valid JSON string.
@since Twitter4J 2.1.7
184936
public static Location createLocation(String rawJSON) throws TwitterException {
        try {
            return new LocationJSONImpl(new JSONObject(rawJSON));
        } catch (JSONException e) {
            throw new TwitterException(e);
        }
    }
646726
public static Credentials createFromJson( String json )
    {
        JSONObject jsonObj = ( JSONObject ) new JSONTokener( json ).nextValue();

        if ( jsonObj.has( PasswordCredentials.PASSWORD ) ) {
            // Password credentials
            return PasswordCredentials.fromJson( jsonObj );
        } else {
            // OAuth2 credentials
            return OAuth2Credentials.fromJson( jsonObj );
        }
    }
150195
public static GeoShape fromJson(String json) {
        try {
            return JsonSerializer.fromString(json, GeoShape.class);
        } catch (IOException e) {
            throw new IllegalArgumentException("Unparseable shape");
        }
    }
1006347
protected JSONObject getJSONObject(final String jsonString) {
    JSONObject json = new JSONObject();
    try {
      json = new JSONObject(jsonString);
    }
    catch(NullPointerException e) {
      LOGGER.error("JSON string cannot be null.", e);
    }
    catch(JSONException e) {
      LOGGER.error("Could not parse string into JSONObject.", e);
    }
    return json;
  }
210483
@JsonCreator
    public static GeoDistance create(String json) {
        try {
            for (GeoDistanceUnit geoDistanceUnit : GeoDistanceUnit.values()) {
                for (String name : geoDistanceUnit.getNames()) {
                    if (json.endsWith(name)) {
                        double value = Double.parseDouble(json.substring(0, json.indexOf(name)));
                        return new GeoDistance(value, geoDistanceUnit);
                    }
                }
            }
            double value = Double.parseDouble(json);
            return new GeoDistance(value, GeoDistanceUnit.METRES);
        } catch (Exception e) {
            e.printStackTrace();
            throw new IllegalArgumentException("Unparseable distance: " + json);
        }
    }
1149347
public StringBuilder toMsg(StringBuilder sb,  String attErrJson) throws APIException {
		return toMsg(sb,errDF.newData().in(TYPE.JSON).load(attErrJson).asObject());
	}
316848
public static ConfigurableJsonFluentAssert assertThatJson(Object json) {
        return new ConfigurableJsonFluentAssert(convertToJson(json, ACTUAL), getPathPrefix(json));
    }
38878
public static String stringify(final JsonNode json) {
        try {
            return json != null ? createObjectMapper().writeValueAsString(json) : "{}";
        } catch (JsonProcessingException jpx) {
            throw new RuntimeException("A problem occurred while stringifying a JsonNode: " + jpx.getMessage(), jpx);
        }
    }
1085620
public static String formatJson(String json) {
    assertInitialization();
    return XLog.sLogConfiguration.jsonFormatter.format(json);
  }
1022159
public static Status createStatus(String rawJSON) throws TwitterException {
        try {
            return new StatusJSONImpl(new JSONObject(rawJSON));
        } catch (JSONException e) {
            throw new TwitterException(e);
        }
    }
1050312
public static <T> T withJsonString(String jsonString,
            TypeReference<T> typeReference) {
        return withBytes(jsonString.getBytes(), typeReference);
    }
110962
@SuppressWarnings("unused")
  public static CarmenContext fromJson(@NonNull String json) {
    Gson gson = new GsonBuilder()
      .registerTypeAdapterFactory(GeocodingAdapterFactory.create())
      .create();
    return gson.fromJson(json, CarmenContext.class);
  }
1178518
public static JsonWebKey jsonWebKeyFromString(String jwkString) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.readValue(jwkString, JsonWebKey.class);
    }
414299
@SuppressWarnings("unchecked")
  public static Object parse(String raw) throws IOException {
    JsonReader jr = new JsonReader(new StringReader(raw));
    try {
      return parseRecursive(jr);
    } finally {
      try {
        jr.close();
      } catch (IOException e) {
        logger.log(Level.WARNING, "Failed to close", e);
      }
    }
  }
699562
public static <T> T fromJsonString(String jsonString, Class<T> clazz) {
        return fromJsonString(jsonString, clazz, null);
    }
510604
static <T> T registerJSONObject(T key, Object json) {
        registeredAtleastOnce = true;
        rawJsonMap.get().put(key, json);
        return key;
    }
844321
protected JsonObject silentlyCreateObjectFromString(String json) {
    JsonObject errorObject = null;

    // We need to swallow exceptions here because it's possible to get a legit
    // Facebook response that contains illegal JSON (e.g.
    // users.getLoggedInUser returning 1240077) - we're only interested in
    // whether or not there's an error_code field present.
    try {
      errorObject = Json.parse(json).asObject();
    } catch (ParseException e) {
      // do nothing here
    }

    return errorObject;
  }