static public Object stringToValue(String s){
  if (s.equals("")) {
    return s;
  }
  if (s.equalsIgnoreCase("true")) {
    return Boolean.TRUE;
  }
  if (s.equalsIgnoreCase("false")) {
    return Boolean.FALSE;
  }
  if (s.equalsIgnoreCase("null")) {
    return JSONObject.NULL;
  }
  char b=s.charAt(0);
  if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') {
    if (b == '0' && s.length() > 2 && (s.charAt(1) == 'x' || s.charAt(1) == 'X')) {
      try {
        return new Integer(Integer.parseInt(s.substring(2),16));
      }
 catch (      Exception ignore) {
      }
    }
    try {
      if (s.indexOf('.') > -1 || s.indexOf('e') > -1 || s.indexOf('E') > -1) {
        return Double.valueOf(s);
      }
 else {
        Long myLong=new Long(s);
        if (myLong.longValue() == myLong.intValue()) {
          return new Integer(myLong.intValue());
        }
 else {
          return myLong;
        }
      }
    }
 catch (    Exception ignore) {
    }
  }
  return s;
}

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