Examples of JsonException


Examples of ar.com.restba.json.JsonException

    if (o == null) {
      put(key, new JsonArray().put(value));
    } else if (o instanceof JsonArray) {
      put(key, ((JsonArray) o).put(value));
    } else {
      throw new JsonException("JsonObject[" + key + "] is not a JsonArray.");
    }
    return this;
  }
View Full Code Here

Examples of blackberry.common.util.json4j.JSONException

    public Parser(Reader reader) throws JSONException {
        super();    
        try {
            this.tokenizer = new Tokenizer(reader, false);
        } catch (IOException iox) {
            JSONException jex = new JSONException("Error occurred during input read.");
            jex.setCause(iox);
            throw jex;
        }
    }
View Full Code Here

Examples of com.alibaba.fastjson.JSONException

                            fieldAnnotation = (JSONField) paramAnnotation;
                            break;
                        }
                    }
                    if (fieldAnnotation == null) {
                        throw new JSONException("illegal json creator");
                    }

                    Class<?> fieldClass = creatorConstructor.getParameterTypes()[i];
                    Type fieldType = creatorConstructor.getGenericParameterTypes()[i];
                    Field field = getField(clazz, fieldAnnotation.name());
                    FieldInfo fieldInfo = new FieldInfo(fieldAnnotation.name(), clazz, fieldClass, fieldType, field);
                    beanInfo.add(fieldInfo);
                }
                return beanInfo;
            }

            Method factoryMethod = getFactoryMethod(clazz);
            if (factoryMethod != null) {
                factoryMethod.setAccessible(true);
                beanInfo.setFactoryMethod(factoryMethod);

                for (int i = 0; i < factoryMethod.getParameterTypes().length; ++i) {
                    Annotation[] paramAnnotations = factoryMethod.getParameterAnnotations()[i];
                    JSONField fieldAnnotation = null;
                    for (Annotation paramAnnotation : paramAnnotations) {
                        if (paramAnnotation instanceof JSONField) {
                            fieldAnnotation = (JSONField) paramAnnotation;
                            break;
                        }
                    }
                    if (fieldAnnotation == null) {
                        throw new JSONException("illegal json creator");
                    }

                    Class<?> fieldClass = factoryMethod.getParameterTypes()[i];
                    Type fieldType = factoryMethod.getGenericParameterTypes()[i];
                    Field field = getField(clazz, fieldAnnotation.name());
                    FieldInfo fieldInfo = new FieldInfo(fieldAnnotation.name(), clazz, fieldClass, fieldType, field);
                    beanInfo.add(fieldInfo);
                }
                return beanInfo;
            }

            throw new JSONException("default constructor not found. " + clazz);
        }

        for (Method method : clazz.getMethods()) {
            String methodName = method.getName();
            if (methodName.length() < 4) {
View Full Code Here

Examples of com.alimama.mdrill.json.JSONException

      jsonObj.put("code", "1");
      jsonObj.put("message", "success");
      jsonObj.put("fcsize", fcsize);
      return callback + "(" + jsonObj.toString() + ")";
    } catch (Exception e) {
      throw new JSONException(e);
    }

  }
View Full Code Here

Examples of com.esotericsoftware.jsonbeans.JsonException

    int start = buffer.position();
    try {
      json.writeValue(object, Object.class, null);
      writer.flush();
    } catch (Exception ex) {
      throw new JsonException("Error writing object: " + object, ex);
    }
    if (INFO && logging) {
      int end = buffer.position();
      buffer.position(start);
      buffer.limit(end);
View Full Code Here

Examples of com.findwise.hydra.JsonException

        requireAction(Action.valueOf((String)queryObject.get("action")));
      }
     
    }
    catch(JsonParseException jse) {
      throw new JsonException(jse);
    }
  }
View Full Code Here

Examples of com.firefly.utils.json.exception.JsonException

  public Object convertTo(JsonReader reader, Class<?> clazz) {
    if(reader.isNull())
      return null;
   
    if(!reader.isObject())
      throw new JsonException("json string is not object format");
   
    Object obj = null;
    try {
      obj = clazz.newInstance();
    } catch (Throwable e) {
      e.printStackTrace();
    }
   
    if(reader.isEmptyObject())
      return obj;
   
    for (int i = 0;;i++) {
      ParserMetaInfo parser = parserMetaInfos[i];
      char[] field = reader.readField(parser.getPropertyName());
      if(!reader.isColon())
        throw new JsonException("missing ':'");
     
      if(field == null) { // 顺序相同,快速跳过
        parser.invoke(obj, reader);
      } else {
        ParserMetaInfo np = find(field);
        if(np != null)
          np.invoke(obj, reader);
        else
          reader.skipValue();
      }
     
      if(i == max)
        break;
     
      char ch = reader.readAndSkipBlank();
      if(ch == '}') // json string 的域数量比元信息少,提前结束
        return obj;

      if(ch != ',')
        throw new JsonException("missing ','");
    }
   
    char ch = reader.readAndSkipBlank();
    if(ch == '}')
      return obj;
   
    if(ch != ',')
      throw new JsonException("json string is not object format");
   
    for(;;) { // json string 的域数量比元信息多,继续读取
      char[] field = reader.readChars();
      if(!reader.isColon())
        throw new JsonException("missing ':'");
     
      ParserMetaInfo np = find(field);
      if(np != null)
        np.invoke(obj, reader);
      else
        reader.skipValue();
     
      char c = reader.readAndSkipBlank();
      if(c == '}') // 读到末尾
        return obj;

     
      if(c != ',')
        throw new JsonException("missing ','");
    }
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.json.exceptions.JsonException

          children.add(factory("array", obj, array, i));
        }
      }
      return children;
    } catch (JSONException e) {
      throw new JsonException(e);
    }
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.json.exceptions.JsonException

      else if (obj instanceof JSONArray)
        throw new JsonArrayException("Can't access a single array entry without index", (JSONArray)obj);
      else
        return new AttributeNode(this, key);
    } catch (JSONException e) {
      throw new JsonException(e);
    }
  }
View Full Code Here

Examples of com.gistlabs.mechanize.document.json.exceptions.JsonException

  @Override
  public String toString() {
    try {
      return new JSONObject().put(name, getValue()).toString();
    } catch (JSONException e) {
      throw new JsonException(e);
    }
  }
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.