Package org.json

Examples of org.json.JSONObject.opt()


        JSONObject clone = new JSONObject(base, JSONObject.getNames(base));
        // Walk parameter list for the merged object and merge recursively.
        String[] fields = JSONObject.getNames(merge);
        for (String field : fields) {
            Object existing = clone.opt(field);
            Object update = merge.get(field);
            if (JSONObject.NULL.equals(existing) || JSONObject.NULL.equals(update)) {
                // It's new custom config, not referenced in the prototype, or
                // it's removing a pre-configured value.
                clone.put(field, update);
View Full Code Here


 
  private void getFields(JSONArray nodes, JSONArray container) throws Exception {
    for (int i = 0; i < nodes.length(); i++) {
      JSONObject node = (JSONObject) nodes.get(i);
     
      JSONArray children = (JSONArray) node.opt("children");
     
      if (children != null && children.length() > 0) {
        // entity node
        getFields(children, container);
      } else {
View Full Code Here

        while (true) {
            if (probe) {
                log();
            }
            String name = read(this.namehuff, this.namehuffext, this.namekeep);
            if (jsonobject.opt(name) != null) {
                throw new JSONException("Duplicate key.");
            }
            jsonobject.put(name, !bit()
                    ? read(this.stringhuff, this.stringhuffext, this.stringkeep)
                    : readValue());
View Full Code Here

    JSONObject payload = getRequest().getPayload();

    Iterator<String> iter = payload.keys();
    while (iter.hasNext()) {
      String key = iter.next();
      Object value = payload.opt(key);
      getSession().configure(command).set(key, value);
    }

    Response resp = new Response();
    resp.setSessionId(getSession().getSessionId());
View Full Code Here

            if (temp == null) {
                throw new Exception(String.format("The node %s could not be found!", path));
            }
        }

        Object value = temp.opt(property);
        if (value == null) {
            throw new Exception(String.format("The node %s did not containt the property %s!", path, property));
        }
    }
View Full Code Here

            if (binaryData == null) {
               return;
            }
            JSONObject payload = new JSONObject(binaryData.toString(CharsetUtil.UTF_8));
            String opCode = (String) payload.get(OpHandler.OP_CODE);
            String cacheName = (String) payload.opt(OpHandler.CACHE_NAME);
            Cache<Object, Object> cache = getCache(cacheName);
           
            OpHandler handler = operationHandlers.get(opCode);
            if (handler != null) {
               handler.handleOp(payload, cache, ctx);
View Full Code Here

    @Override
    protected <T> T getObjectFieldValue( Object inputNode, String key, Function<Object, T> valueDeserializer )
        throws Exception
    {
        JSONObject json = (JSONObject) inputNode;
        Object valueNode = json.opt( key );
        if( JSONObject.NULL.equals( valueNode ) )
        {
            return null;
        }
        T value = valueDeserializer.map( valueNode );
View Full Code Here

               JSONObject row = rows.getJSONObject( i );
               JSONArray cells = row.getJSONArray( "c" );
               for (int j = 0; j < cells.length(); j++)
               {
                  JSONObject cell = cells.getJSONObject( j );
                  Object value = cell.opt( "v" );
                  String formatted = cell.optString("f");

                  if (cols.getJSONObject( j ).getString( "type" ).equals("datetime") && value != null)
                     value = Dates.fromString( value.toString() );
                  else if (cols.getJSONObject( j ).getString( "type" ).equals("date") && value != null)
View Full Code Here

    JSONObject nunaliit_attachments = doc.getJSONObject("nunaliit_attachments");
    JSONObject files = nunaliit_attachments.getJSONObject("files");

    // Verify no collision within nunaliit_attachments.files
    {
      Object obj = files.opt(newAttachmentName);
      if( null != obj ){
        throw new Exception("Can not rename attachment because of name collision");
      }
    }
   
View Full Code Here

    Collection<JSONObject> userDocs = userDb.getDocuments(docIds);
   
    // Work around for bug in CouchDb 1.4.0
    if( userDocs.size() > 0 ) {
      JSONObject firstUser = userDocs.iterator().next();
      Object returnedId = firstUser.opt("_id");
      if( null == returnedId ){
        // Perform request, one at a time
        List<JSONObject> tempUserDocs = new Vector<JSONObject>();
        for(String id : docIds){
          try {
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.