Package org.json

Examples of org.json.JSONTokener.nextValue()


      int statusCode= postMethod.getStatusCode();
      if (statusCode!=HttpStatus. SC_OK)
        throw new ClientError("HTTP Status - " +
          HttpStatus.getStatusText(statusCode) + " (" + statusCode + ")");
      JSONTokener tokener= new JSONTokener(postMethod.getResponseBodyAsString());
      Object rawResponseMessage= tokener.nextValue();
      JSONObject responseMessage= (JSONObject)rawResponseMessage;
      if (responseMessage==null)
        throw new ClientError("Invalid response type - " + rawResponseMessage.getClass());
      return responseMessage;   
    } catch (ParseException e) {
View Full Code Here


          new NameValuePair("sort_type", "desc") };
      String contactsUrl = lastUrl.substring(0, lastUrl.lastIndexOf("/"))
          + "/addr_member.php";
      String json = doPost(contactsUrl, params);
      JSONTokener jsonTokener = new JSONTokener(json);
      Object o = jsonTokener.nextValue();
      JSONObject jsonObj = (JSONObject) o;
      JSONObject jsonData = jsonObj.getJSONObject("data");
      JSONArray jsonContacts = jsonData.getJSONArray("contact");
      List<Contact> contacts = new ArrayList<Contact>();
      for (int i = 0; i < jsonContacts.length(); i++) {
View Full Code Here

     * @throws org.json.JSONException
     */
    protected JSONObject parseJSON(String content, String startTag) throws JSONException {
        String json = content.substring(content.indexOf(startTag) + startTag.length());
        JSONTokener jsonTokener = new JSONTokener(json);
        Object o = jsonTokener.nextValue();
        return (JSONObject) o;
    }

    /**
     * 将一段字符串解析为JSONObject
 
View Full Code Here

     */
    protected JSONObject parseJSON(String content, String startTag, String endTag) throws JSONException {
        String sub_content = content.substring(content.indexOf(startTag) + startTag.length());
        String json = sub_content.substring(0, sub_content.indexOf(endTag));
        JSONTokener jsonTokener = new JSONTokener(json);
        Object o = jsonTokener.nextValue();
        return (JSONObject) o;
    }

    /**
     * 判断是否是正确的email地址
 
View Full Code Here

                                                          jsonString));
            case '}':
                return;
            default:
                x.back();
                key = x.nextValue().toString();
            }

            /*
             * The key is followed by ':'. We will also tolerate '=' or '=>'.
             */
 
View Full Code Here

                }
            } else if (c != ':') {
                throw new IllegalArgumentException(format("String '%s' is not a valid JSON object representation, expected a ':' after the key '%s'",
                                                          jsonString, key));
            }
            Object value = x.nextValue();

            // guard from null values
            if (value != null) {
                if (value instanceof JSONArray) { // only plain simple arrays in this version
                    JSONArray array = (JSONArray) value;
View Full Code Here

                            throws IOException
                        {
                            try
                            {
                                JSONTokener tokener = new JSONTokener( item );
                                JSONObject entity = (JSONObject) tokener.nextValue();
                                String id = entity.getString( JSONKeys.identity.name() );
                                store.put( new EntityReference( id ), item );
                            }
                            catch( JSONException e )
                            {
View Full Code Here

     */
    public Object fromJSON(String jsonString) throws UnmarshallException {
        JSONTokener tok = new JSONTokener(jsonString);
        Object json;
        try {
            json = tok.nextValue();
        } catch (JSONException e) {
            throw new UnmarshallException("couldn't parse JSON", e);
        }
        SerializerState state = new SerializerState();
        return this.unmarshall(state, null, json);
View Full Code Here

  throws UnmarshallException
    {
  JSONTokener tok =   new JSONTokener(s);
  Object json;
  try {
      json = tok.nextValue();
  } catch(JSONException e) {
      throw new UnmarshallException("couldn't parse JSON");
  }
  SerializerState state = new SerializerState();
  return unmarshall(state, null, json);
View Full Code Here

         
          fis.close();
          fis = null;
         
          JSONTokener tokener = new JSONTokener(sw.toString());
          Object infoObj = tokener.nextValue();
          if( infoObj instanceof JSONObject ) {
            JSONObject info = (JSONObject)infoObj;
           
            {
              String testName = info.optString(DocumentStoreProcess.ATT_INFO_NAME);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.