Try to convert a string into a number, boolean, or null. If the string can't be converted, return the string.

@param string A String.
@return A simple JSON value.
966845
public static function stringToValue($string)
	{
		if($string == '')
		{
			return $string;
		}
		if(is_float($string))
		{
			return (float) $string;
		}
		if(is_int($string))
		{
			return (int) $string;
		}
		if(strtolower($string) == 'true')
		{
			return true;
		}
		if(strtolower($string) == 'false')
		{
			return false;
		}
		if(strtolower($string) == 'null')
		{
			return NULL;
		}
		
		return $string;
	}
1023083
function fromString( $string )
    {
        $dataType = $this->dataType();
        if ( $dataType )
            return $dataType->fromString( $this, $string );
        else
            return false;
    }
246900
public Object fromString(String str)
    {
        if (StringUtils.isNotBlank(str)) {
            ObjectMapper objectMapper = new ObjectMapper();

            try {
                return objectMapper.readValue(str, Object.class);
            } catch (Exception e) {
                LOGGER.info("Failed to parse JSON [{}]: ", StringUtils.abbreviate(str, 32),
                    ExceptionUtils.getRootCauseMessage(e));

                return null;
            }
        }

        return null;
    }
815556
public static function decode(string $string)
    {
        $content = json_decode($string, true);

        self::throwOnError();

        return $content;
    }
1036910
public static int stringToInteger(String string) {
        string = string.trim();
        if (Checker.isNumber(string)) {
            return Integer.parseInt(string);
        }
        return -1;
    }
227047
@Override
    protected String convertToString(Object value) throws Throwable {
		PhoneNumber number = (PhoneNumber) value; 
		return number.getNumber();
    }
612374
public function convert($string)
    {
        $json = json_decode($string, true);
        if (JSON_ERROR_NONE !== ($jsonErrorCode = json_last_error())) {
            $message = "An error occured while decoding the JSON input:\n";
            $message .= $this->jsonDecodeErrorMessage($jsonErrorCode);
            $message .= "\nInput JSON:\n\n" . $string;
            throw new ParserException($message);
        }

        return $json;
    }
473784
public static boolean isNumeric(String string) {
        if (string == null || string.length() == 0)
            return false;

        int l = string.length();
        for (int i = 0; i < l; i++) {
            if (!Character.isDigit(string.codePointAt(i)))
                return false;
        }
        return true;
    }
107709
private static String getJsonValueAsNumberString(JsonValue value) {
        return (value != null && value.getValueType() == ValueType.NUMBER) ? value.toString() : null;
    }
30569
public static Object convertStringToObject(String string)
    {
        try {
            return ClassServiceUtility.getClassService().convertStringToObject(string, null);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e.getMessage());
        }
    }
737445
public int find(String string) {
        if (m_strings == null) {
            return -1;
        }

        for (int i = 0; i < m_strings.length - 1; i++) {
            if (m_strings[i].equals(string)) {
                return i;
            }
        }

        return -1;
    }
919647
public static String toVerb(String string) {
		if (string == null) {
			return string;
		}
		if (string.length() == 1) {
			return string.toLowerCase();
		}
		return string.substring(0, 1).toLowerCase() + string.substring(1, string.length());
	}
567429
public static HttpString tryFromString(String string) {
        HttpString cached = Headers.fromCache(string);
        if(cached != null) {
            return cached;
        }
        final int len = string.length();
        final byte[] bytes = new byte[len];
        for (int i = 0; i < len; i++) {
            char c = string.charAt(i);
            if (c > 0xff) {
                return null;
            }
            bytes[i] = (byte) c;
        }
        return new HttpString(bytes, string);
    }
533285
public static String getString(JSONValue value) {
        if (value == null)
            return null;
        if (!(value instanceof JSONString))
            throw new JSONException(NOT_A_STRING);
        return ((JSONString)value).toString();
    }
698186
public String get(JcString string) {
		Object val = this.getFor(string);
		if (val != null)
			return (String)val;
		return null;
	}
95645
public static function fromString( $string ) {
		$values = [
			'1'     => true,
			'y'     => true,
			'yes'   => true,
			'true'  => true,

			'0'     => false,
			'n'     => false,
			'no'    => false,
			'false' => false,
		];

		foreach ( $values as $value => $boolean ) {
			if ( strtolower( $value ) === strtolower( $string ) ) {
				return $boolean;
			}
		}

		// rely on PHP's string to boolean conversion in all other cases
		return (bool) $string;
	}
1245016
public static ULong ulong(String value) throws NumberFormatException {
        return value == null ? null : ULong.valueOf(value);
    }