@Override protected JsonValue computeNext() { if(!it.hasNext()){ return endOfData(); } return JsonValue.of(it.next()); } };
/** * Parse the json string and returns the result as {@link JsonValue}. */ public static JsonValue parse(String json) { return JsonValue.of(decode(json)); }
/** * Wraps the property value as {@link JsonValue}. */ public JsonValue getValue(String key){ Object o = get(key); return null == o ? null : JsonValue.of(o); }
/** * Parse all the items to the given type using {@link JsonParsable#parseJson(JsonValue)}. */ public <T extends JsonParsable> List<T> parseList(Supplier<T> factory) { List<T> newList = new ArrayList<>(); for(Object item : this.list) { T obj = factory.get(); obj.parseJson(JsonValue.of(item)); newList.add(obj); } return newList; }
/** * Parse the json string and returns the result as {@link JsonValue}. */ public static JsonValue parse(Reader json) { return JsonValue.of(decode(json)); }
public JsonValue getValue(int i){ Object o = get(i); return null == o ? null : JsonValue.of(o); }
/** * Parse all the items to the given type using {@link JsonParsable#parseJson(JsonValue)}. */ public <T extends JsonParsable> List<T> parseList(Class<T> type) { List<T> newList = new ArrayList<>(); ReflectClass rc = ReflectClass.of(type); for(Object item : this.list) { T obj = rc.newInstance(); obj.parseJson(JsonValue.of(item)); newList.add(obj); } return newList; }
public void read(MetaApi api, Resource resource, boolean global) { JsonValue v = JsonValue.of(JSON.decode(resource.getContent())); String path = !global ? PathDefParser.path("/app/operations/", resource) : null; if(v.isObject()) { read(api, global, path,(Map)v.raw()); }else if(v.isArray()) { for(Object map : v.asArray()) { read(api, global, path,(Map)map); } }else { throw new IllegalStateException("Invalid json format of tags, must be an array or an object"); } }