Package org.json

Examples of org.json.JSONException


      return null;
    final String guess = obj.getString(field);
    try {
      return dateFormat.parse(guess);
    } catch (ParseException e) {
      throw new JSONException("Bad date value " + guess);
    }
  }
View Full Code Here


    protected void loadFromJSONObject(final JSONObject obj, Database db) throws JSONException {
        m_targetTableName = obj.getString(Members.TARGET_TABLE_NAME.name());
        if (db != null || m_targetTableName.equals("")) {
            Table table = db.getTables().get(m_targetTableName);
            if (table == null) {
                throw new JSONException("Unable to retrieve catalog object for table '" + m_targetTableName + "'");
            }
        }
    }
View Full Code Here

       
        m_targetTableName = obj.getString(Members.TARGET_TABLE_NAME.name());
        if (db != null || m_targetTableName.equals("")) {
            Table table = db.getTables().get(m_targetTableName);
            if (table == null)
                throw new JSONException("Unable to retrieve catalog object for table '" + m_targetTableName + "'");
        }
    }
View Full Code Here

        assert(catalog_proc != null) : "Unexpected procedure '" + this.catalog_item_name + "'";
        try {
            super.paramsFromJSONObject(object, catalog_proc.getParameters(), "type");
        } catch (Exception ex) {
            LOG.fatal("Failed to extract procedure params for txn #" + this.txn_id, ex);
            throw new JSONException(ex);
        }
       
        JSONArray jsonQueries = object.getJSONArray(Members.QUERIES.name());
        for (int i = 0; i < jsonQueries.length(); i++) {
            JSONObject jsonQuery = jsonQueries.getJSONObject(i);
View Full Code Here

        if (catalog_stmt == null) {
            catalog_stmt = catalog_proc.getStatements().getIgnoreCase(CatalogKey.getNameFromKey(this.catalog_item_name));
            if (catalog_stmt == null) {
                String msg = "Procedure '" + catalog_proc.getName() + "' does not have a Statement '" + this.catalog_item_name + "'";
                msg += "\nValid Statements: " + CatalogUtil.debug(catalog_proc.getStatements());
                throw new JSONException(msg);
            }
        }
        // HACK
        this.catalog_item_name = CatalogKey.createKey(catalog_stmt);
       
        try {
            super.paramsFromJSONObject(object, catalog_stmt.getParameters(), "javatype");
        } catch (Exception ex) {
            LOG.fatal("Failed to load query trace for " + this.catalog_item_name);
            throw new JSONException(ex);
        }
    }
View Full Code Here

            V vertex = null;
            try {
                vertex = v_class.newInstance();
            } catch (Exception ex) {
                LOG.fatal("Failed to create new instance of " + v_class.getName());
                throw new JSONException(ex);
            }
            JSONObject jsonVertex = jsonArray.getJSONObject(i);
            vertex.fromJSON(jsonVertex, catalog_db);
            graph.addVertex(vertex);
        } // FOR
View Full Code Here

     */
    public static <E extends Enum<?>, T> void fieldsToJSON(JSONStringer stringer, T object, Class<? extends T> base_class, E members[]) throws JSONException {
        try {
            fieldsToJSON(stringer, object, base_class, ClassUtil.getFieldsFromMembersEnum(base_class, members));
        } catch (NoSuchFieldException ex) {
            throw new JSONException(ex);
        }
    }
View Full Code Here

                } else {
                    writeFieldValue(stringer, f_class, f_value);
                    addClassForField(stringer, json_key, f_class, f_value);
                }
            } catch (Exception ex) {
                throw new JSONException(ex);
            }
        } // FOR
    }
View Full Code Here

                    // The key can't be a raw CatalogType because CatalogKey
                    // won't know how to
                    // deserialize it on the other side
                    Class<?> key_class = e.getKey().getClass();
                    if (key_class.equals(CatalogType.class))
                        throw new JSONException("CatalogType is not allowed to be the map key");
                    key_value = makePrimitiveValue(key_class, e.getKey()).toString();
                }
                stringer.key(key_value);

                // We can also handle null values. Where is your god now???
View Full Code Here

            inner_classes.addAll(ClassUtil.getGenericTypes(field_handle));
            Collections.reverse(inner_classes);

            JSONArray json_inner = json_object.getJSONArray(json_key);
            if (json_inner == null)
                throw new JSONException("No array exists for '" + json_key + "'");
            readCollectionField(json_inner, catalog_db, (Collection) field_object, inner_classes);

        // Maps
        } else if (field_object instanceof Map) {
            if (debug.val)
                LOG.debug("Field " + json_key + " is a map");
            assert (field_object != null);
            Stack<Class<?>> inner_classes = new Stack<Class<?>>();
            inner_classes.addAll(ClassUtil.getGenericTypes(field_handle));
            Collections.reverse(inner_classes);

            JSONObject json_inner = json_object.getJSONObject(json_key);
            if (json_inner == null)
                throw new JSONException("No object exists for '" + json_key + "'");
            readMapField(json_inner, catalog_db, (Map) field_object, inner_classes);

            // Everything else...
        } else {
            Class<?> explicit_field_class = JSONUtil.getClassForField(json_object, json_key);
View Full Code Here

TOP

Related Classes of org.json.JSONException

Copyright © 2018 www.massapicom. 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.