public static Object stringToValue(String string){
  Double d;
  if (string.equals("")) {
    return string;
  }
  if (string.equalsIgnoreCase("true")) {
    return Boolean.TRUE;
  }
  if (string.equalsIgnoreCase("false")) {
    return Boolean.FALSE;
  }
  if (string.equalsIgnoreCase("null")) {
    return JSONObject.NULL;
  }
  char b=string.charAt(0);
  if ((b >= '0' && b <= '9') || b == '-') {
    try {
      if (string.indexOf('.') > -1 || string.indexOf('e') > -1 || string.indexOf('E') > -1) {
        d=Double.valueOf(string);
        if (!d.isInfinite() && !d.isNaN()) {
          return d;
        }
      }
 else {
        Long myLong=new Long(string);
        if (string.equals(myLong.toString())) {
          if (myLong == myLong.intValue()) {
            return myLong.intValue();
          }
 else {
            return myLong;
          }
        }
      }
    }
 catch (    Exception ignore) {
    }
  }
  return string;
}

public static Object stringToValue ( String string ) { Double d ; if ( string . equals ( "" ) ) { return string ; } if ( string . equalsIgnoreCase ( "true" ) ) { return Boolean . TRUE ; } if ( string . equalsIgnoreCase ( "false" ) ) { return Boolean . FALSE ; } if ( string . equalsIgnoreCase ( "null" ) ) { return JSONObject . NULL ; } char b = string . charAt ( 0 ) ; if ( ( b >= '0' && b <= '9' ) || b == '-' ) { try { if ( string . indexOf ( '.' ) > - 1 || string . indexOf ( 'e' ) > - 1 || string . indexOf ( 'E' ) > - 1 ) { d = Double . valueOf ( string ) ; if ( ! d . isInfinite ( ) && ! d . isNaN ( ) ) { return d ; } } else { Long myLong = new Long ( string ) ; if ( string . equals ( myLong . toString ( ) ) ) { if ( myLong == myLong . intValue ( ) ) { return myLong . intValue ( ) ; } else { return myLong ; } } } } catch ( Exception ignore ) { } } return string ; }
try to convert a string into a number , boolean , or null . if the string can ' t be converted , return the string .
