public String toString() { return jsonValue.getClass().getSimpleName() + ": " + jsonValue.render(false); }
public JsonValue getItem(int index) { JSONValue item = ((JSONArray) jsonValue).get(index); return new JsonValue(item); }
key, current)); JSONValue value = ((JSONObject) current.jsonValue).get((String) key); if (value == null) { throw new IllegalArgumentException(format("Key '%s' does not refer to any attribute of %s",
public Object toJava(JSONValue aValue, Class aRequestedClass) throws MapperException { //lenient to the data to be converted. if(aValue.isDecimal()) return ((JSONDecimal)aValue).getValue().toString(); if(aValue.isInteger()) return ((JSONInteger)aValue).getValue().toString(); if (!aValue.isString()) throw new MapperException("StringMapper cannot map class: " + aValue.getClass().getName()); return ((JSONString) aValue).getValue(); } }
public Let(String aName, JSONObject aRule, HashMap<String,Validator> aRuleset) throws ValidationException { super(aName, aRule); ruleset = aRuleset; ValidatorUtil.requiresAttribute(aRule, ValidatorUtil.PARAM_RULES, JSONArray.class); List<JSONValue> lRules = ((JSONArray) aRule.get(ValidatorUtil.PARAM_RULES)).getValue(); for (JSONValue lRule : lRules) { JSONValue lVal = lRule; ValidatorUtil.buildValidator(lVal, ruleset); } ValidatorUtil.requiresAttribute(aRule, ValidatorUtil.PARAM_REF, JSONString.class); ref = ((JSONString) aRule.get(ValidatorUtil.PARAM_REF)).getValue(); }
private JSONObject marshallPrimitive(String aType, String aValue) { final JSONObject lElement = new JSONObject(); lElement.getValue().put(RNDR_ATTR_KIND, new JSONString(RNDR_PRIM)); lElement.getValue().put(RNDR_ATTR_TYPE, new JSONString(aType)); lElement.getValue().put(RNDR_ATTR_VALUE, new JSONString(aValue)); return lElement; }
public void renderValue(Object aObj, JSONObject aObjectElement, JSONMarshall aMarshall, HashMap aPool) throws MarshallException { aObjectElement.getValue().put(JSONMarshall.RNDR_ATTR_VALUE, new JSONString(dateFormat.format((Date) aObj))); }
public Ref(String aName, JSONObject aRule, HashMap<String,Validator> aRuleset) throws ValidationException { super(aName, aRule); ruleset = aRuleset; ValidatorUtil.requiresAttribute(aRule, ValidatorUtil.PARAM_REF, JSONString.class); ref = ((JSONString) aRule.get(ValidatorUtil.PARAM_REF)).getValue(); }
public String getString(Object... keys) { String jsString = getValue(keys).render(false); return jsString.substring(1, jsString.length() - 1); }
public Or(String aName, JSONObject aRule, HashMap<String,Validator> aRuleset) throws ValidationException { super(aName, aRule); ValidatorUtil.requiresAttribute(aRule, ValidatorUtil.PARAM_RULES, JSONArray.class); List<JSONValue> lRules = ((JSONArray) aRule.get(ValidatorUtil.PARAM_RULES)).getValue(); for (JSONValue lRule : lRules) { Validator lValidator = ValidatorUtil.buildValidator(lRule, aRuleset); rules.add(lValidator); } }
/** * Convert the JSON value into a string representation (JSON representation). * @param pretty Indicating if the print should be made pretty (human readers) or compact (transmission or storage). * @return A JSON representation. */ public String render(boolean pretty) { return render(pretty, ""); }
public Object parseValue(JSONObject aObjectElement, JSONMarshall aMarshall, HashMap aPool) throws MarshallException { JSONMarshall.requireStringAttribute(aObjectElement, JSONMarshall.RNDR_ATTR_VALUE); return new BigDecimal(((JSONString) aObjectElement.get(JSONMarshall.RNDR_ATTR_VALUE)).getValue()); }
public Object parseValue(JSONObject aObjectElement, JSONMarshall aMarshall, HashMap aPool) throws MarshallException { JSONMarshall.requireStringAttribute(aObjectElement, JSONMarshall.RNDR_ATTR_VALUE); return new BigInteger(((JSONString) aObjectElement.get(JSONMarshall.RNDR_ATTR_VALUE)).getValue()); }