Examples of JSONException


Examples of com.granule.json.JSONException

     * @param ordered Flag to denote if the parse should contruct JSON objects and arrays which maintain serialization order of the attributes.    
     *
     * @throws JSONException Thrown if an IO error (read incomplete token) occurs.
     */
    public Object parseValue(boolean ordered) throws JSONException {
        if (lastToken == Token.TokenEOF) throw new JSONException("Expecting property value " + tokenizer.onLineCol());

        try {
            if (lastToken.isNumber()) {
                Object result = lastToken.getNumber();
                lastToken = tokenizer.next();
                return result;
            }

            if (lastToken.isString()) {
                Object result = lastToken.getString();
                lastToken = tokenizer.next();
                return result;
            }

            if (lastToken == Token.TokenFalse) {
                lastToken = tokenizer.next();
                return Boolean.FALSE;
            }

            if (lastToken == Token.TokenTrue) {
                lastToken = tokenizer.next();
                return Boolean.TRUE;
            }

            if (lastToken == Token.TokenNull) {
                lastToken = tokenizer.next();
                return null;
            }

            if (lastToken == Token.TokenBrackL) return parseArray(ordered, null);
            if (lastToken == Token.TokenBraceL) return parseObject(ordered, null);

        } catch (IOException iox) {
            JSONException jex = new JSONException("Error occurred during value input read.");
            jex.initCause(iox);
            throw jex;
        }
        throw new JSONException("Invalid token " + tokenizer.onLineCol());
    }
View Full Code Here

Examples of com.granule.json.JSONException

                                                    }
                                                }
                                            }
                                        } else {
                                            // Dunno?
                                            throw new JSONException("Unknown type: [" + vClazz.getName() + "]");
                                        }
                                    } else {
                                        try {
                                            m = clazz.getMethod(setter, (Class[])null);
                                        } catch (NoSuchMethodException nmex){
                                            // Ignore, no setter.
                                        }
                                    }
                                    if (m != null) {
                                        m.invoke(obj, new Object[] { val });
                                    }
                                }
                            }
                        }
                    } else {
                        throw new JSONException("Could not locate class: [" + cName + "]");
                    }
                } catch (Exception ex) {
                    if (ex instanceof JSONException) {
                        throw (JSONException)ex;
                    } else {
                        JSONException jex = new JSONException("Error in converting JSON to Java Class");
                        jex.initCause(ex);
                        throw jex;
                    }
                }
            } else {
                throw new JSONException("Provided JSONObject does not contain attributes '_classname' or '_type'");
            }
        }
        return obj;
    }
View Full Code Here

Examples of com.oltpbenchmark.util.json.JSONException

     */
    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

Examples of com.zaranux.os.server.util.JSONException

     * so that you can test for a digit or letter before attempting to parse
     * the next number or identifier.
     */
    public void back() throws JSONException {
        if (useLastChar || index <= 0) {
            throw new JSONException("Stepping back two steps is not supported");
        }
        index -= 1;
        useLastChar = true;
    }
View Full Code Here

Examples of elemental.json.JsonException

    }

    public static Object decodeCustomType(Type targetType, JsonValue value,
            ConnectorTracker connectorTracker) {
        if (isInternalType(targetType)) {
            throw new JsonException("decodeCustomType cannot be used for "
                    + targetType + ", which is an internal type");
        }

        // Try to decode object using fields
        if (value.getType() == JsonType.NULL) {
View Full Code Here

Examples of external.JSON.JSONException

                if (x instanceof JSONString) {
                    Object object;
                    try {
                        object = ((JSONString)x).toJSONString();
                    } catch (Exception e) {
                        throw new JSONException(e);
                    }
                    if (object instanceof String) {
                        return (String)object;
                    }
                    throw new JSONException("Bad value from toJSONString: " + object);
                }
                if (x instanceof Number) {
                    return JSONObject.numberToString((Number)x);
                }
                if (x instanceof Boolean || x instanceof JSONObject ||
View Full Code Here

Examples of flexjson.JSONException

        Object source = context.getSource();
        if( source instanceof Map ) {
            Map map = (Map)source;
            return types.get( map.get( fieldname ) );
        } else {
            throw new JSONException( String.format("%s: Don't know how to locate types for source %s using fieldname %s.  TypeLocator requires the source object be a java.util.Map in order to work.", context.getCurrentPath(), source.getClass(), fieldname ) );
        }
    }
View Full Code Here

Examples of groovy.json.JsonException

            } else {
                // TODO move unicode 0 to separate file to avoid doc parsing issues
                return '\u0000';
            }
        } catch (Exception ex) {
            throw new JsonException(exceptionDetails("unable to advance character"), ex);
        }
    }
View Full Code Here

Examples of javax.json.JsonException

            buf[0] = (byte)b1;
            buf[1] = (byte)b2;
            buf[2] = (byte)b3;
            buf[3] = (byte)b4;
        } catch (IOException ioe) {
            throw new JsonException("I/O error while auto-detecting the encoding of stream", ioe);
        }
    }
View Full Code Here

Examples of net.hearthstats.updater.exception.JsonException

    if (value == null) {
      return null;
    } else if (value instanceof JSONObject) {
      return new JsonWrapper(context + "." + key, (JSONObject) value);
    } else {
      throw new JsonException("Expected " + context + "." + key + " to be JSONObject but it is " + value.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.