Package org.json

Examples of org.json.JSONTokener.nextValue()


                }
            } else if (c != ':') {
                throw new IllegalArgumentException(format("String '%s' is not a valid JSON object representation, expected a ':' after the key '%s'",
                                                          jsonBody, 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


            throw new Exception("creation of attachment is not supported");
          } else {
            // Create a document
            BufferedReader reader = req.getReader();
            JSONTokener tokener = new JSONTokener(reader);
            Object obj = tokener.nextValue();
            if( obj instanceof JSONObject ){
              JSONObject doc = (JSONObject)obj;
              JSONObject result = actions.modifyDocument(authContext, dbIdentifier, docId, doc);
              sendJsonResponse(resp, result);
View Full Code Here

          break;
        case END_OBJECT:
          return tokener;
        default:
          tokener.back();
          key = tokener.nextValue().toString();
        }

        c = tokener.nextClean();

        if (c != KEY_VALUE_SEPARATOR) {
View Full Code Here

        if (c != KEY_VALUE_SEPARATOR) {
          LOG.error(String.format("Expected a %c after a key", c));
        }

        if (key != null && !key.equals("results")) {
          tokener.nextValue();
        } else {
          /* starting array */
          c = tokener.nextClean();
          if (c != START_ARRAY) {
            LOG.error("'results' is expected to be an array");
View Full Code Here

      tokener.back();
      return new JSONArray(tokener);
    }
    if (Character.isDigit(firstChar)) {
      tokener.back();
      return tokener.nextValue();
    }
    tokener.back();
    return tokener.nextValue();
  }
View Full Code Here

    if (Character.isDigit(firstChar)) {
      tokener.back();
      return tokener.nextValue();
    }
    tokener.back();
    return tokener.nextValue();
  }

  public static String reformat(String inputJson) {
    String outputJson = new String(inputJson);
    try {
View Full Code Here

    }

    JSONObject jsonObj = null;
    try {
      JSONTokener jsonTokener = new JSONTokener("{"+optionsString+"}");
      Object obj = jsonTokener.nextValue();
      if( obj instanceof JSONObject ) {
        jsonObj = (JSONObject)obj;
      } else {
        throw new Exception("Unexpected returned object type: "+obj.getClass().getSimpleName());
      }
View Full Code Here

    }

    JSONObject jsonObj = null;
    try {
      JSONTokener jsonTokener = new JSONTokener("{"+optionsString+"}");
      Object obj = jsonTokener.nextValue();
      if( obj instanceof JSONObject ) {
        jsonObj = (JSONObject)obj;
      } else {
        throw new Exception("Unexpected returned object type: "+obj.getClass().getSimpleName());
      }
View Full Code Here

  protected List<Query> parseQueriesJson(String queriesString) throws Exception {
    // Parse request into a JSON object
    JSONObject jsonObj = null;
    {
      JSONTokener jsonTokener = new JSONTokener(queriesString);
      Object obj = jsonTokener.nextValue();
      if( obj instanceof JSONObject ) {
        jsonObj = (JSONObject)obj;
      } else {
        throw new Exception("Unexpected object type for queries: "+obj.getClass().getSimpleName());
      }
View Full Code Here

  protected List<Query> parseQueriesJson(String queriesString) throws Exception {
    // Parse request into a JSON object
    JSONObject jsonObj = null;
    {
      JSONTokener jsonTokener = new JSONTokener(queriesString);
      Object obj = jsonTokener.nextValue();
      if( obj instanceof JSONObject ) {
        jsonObj = (JSONObject)obj;
      } else {
        throw new Exception("Unexpected object type for queries: "+obj.getClass().getSimpleName());
      }
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.