@Override protected Object readInternal(Type resolvedType, Reader reader) throws Exception { return getJsonb().fromJson(reader, resolvedType); }
@Override protected Object readInternal(Type resolvedType, Reader reader) throws Exception { return getJsonb().fromJson(reader, resolvedType); }
@Override public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { Jsonb jsonb = getJsonb(type); try { return jsonb.fromJson(entityStream, genericType); } catch (JsonbException e) { throw new ProcessingException(LocalizationMessages.ERROR_JSONB_DESERIALIZATION(), e); } }
@Override public Object parse(final TypeLiteral<?> type, final Context ctx) throws Throwable { MediaType ctype = ctx.type(); if (ctype.isAny()) { // */* return ctx.next(); } if (ctype.matches(this.type)) { return ctx .ifbody(body -> jsonb.fromJson(body.text(), type.getType())) .ifparam(values -> jsonb.fromJson(values.first(), type.getType())); } return ctx.next(); }
@Override public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws java.io.IOException, javax.ws.rs.WebApplicationException { Jsonb jsonb = getJsonb(type); final EmptyCheckInputStream is = new EmptyCheckInputStream(entityStream); try { return jsonb.fromJson(is, genericType); // If null is returned, considered to be empty stream } catch (Throwable e) { if (is.isEmpty()) { return null; } // detail text provided in logger message throw new ProcessingException(Messages.MESSAGES.jsonBDeserializationError(e, e.getMessage()), e); } }
private T getT(String json) { if (Objects.nonNull(json)) { return JSONB.fromJson(json, clazz); } return null; }
@Override public Object decode(final byte[] value, final Type expectedType) { if (!Class.class.isInstance(expectedType)) { throw new IllegalArgumentException("Unsupported type: " + expectedType); } final Class<?> clazz = Class.class.cast(expectedType); return jsonb.fromJson(new ByteArrayInputStream(value), clazz); } }
@Override public T readFrom(final Class<T> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, String> httpHeaders, final InputStream entityStream) throws IOException, WebApplicationException { return getJsonb(type).fromJson(entityStream, genericType); }
@Override public <T> T get(TypeSupplier<T> typeSupplier) throws NullPointerException, UnsupportedOperationException { Objects.requireNonNull(typeSupplier, "typeSupplier is required"); return JSONB.fromJson(json, typeSupplier.get()); }
@Override protected T readObject(Reader reader, ResolvableType type) throws IOException { return this.jsonb.fromJson(reader, type.getType()); }
@Override public Iterator<T> iterator() { return StreamSupport.stream(queue.spliterator(), false) .map(s -> JSONB.fromJson(s.toString(), clazz)) .collect(Collectors.toList()).iterator(); }
@Override public Iterator<T> iterator() { return StreamSupport.stream(arrayList.spliterator(), false) .map(s -> JSONB.fromJson(s.toString(), clazz)) .collect(toList()).iterator(); }
@Override public <T1> T1[] toArray(T1[] t1s) { requireNonNull(t1s, "arrys is required"); return StreamSupport.stream(arrayList.spliterator(), false) .map(s -> JSONB.fromJson(s.toString(), clazz)) .toArray(size -> t1s); }
@Override public Object[] toArray() { return StreamSupport.stream(arrayList.spliterator(), false) .map(s -> JSONB.fromJson(s.toString(), clazz)) .toArray(Object[]::new); }
static JsonObject toJson(Jsonb jsonb, Object value) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); jsonb.toJson(value, stream); InputStream inputStream = new ByteArrayInputStream(stream.toByteArray()); Map<String, ?> map = jsonb.fromJson(inputStream, TYPE); return JsonObject.from(map); } }
public <T> Record toRecord(final T data, final Supplier<Jsonb> jsonbProvider, final Supplier<RecordBuilderFactory> recordBuilderProvider) { if (Record.class.isInstance(data)) { return Record.class.cast(data); } if (JsonObject.class.isInstance(data)) { return json2Record(recordBuilderProvider.get(), JsonObject.class.cast(data)); } final Jsonb jsonb = jsonbProvider.get(); return json2Record(recordBuilderProvider.get(), jsonb.fromJson(jsonb.toJson(data), JsonObject.class)); }
public static TaskBean getTaskBpm(String taskId) { Response response = getWebTarget() .path(TASK) .path(taskId) .request(MediaType.APPLICATION_JSON_TYPE) .get(); if (isStatusOk(response)) { String json = response.readEntity(String.class); return JsonbBuilder.create().fromJson(json, TaskBean.class); } return null; }
public static TaskBean getTaskBpm(String taskId) { Response response = getWebTarget() .path(TASK) .path(taskId) .request(MediaType.APPLICATION_JSON_TYPE) .get(); if (isStatusOk(response)) { String json = response.readEntity(String.class); return JsonbBuilder.create().fromJson(json, TaskBean.class); } return null; }
@Override public V put(K key, V value) { Objects.requireNonNull(key, "key is required"); Objects.requireNonNull(value, "value is required"); JsonObject json = map.put(key.toString(), JsonObjectCouchbaseUtil.toJson(JSONB, value)); if (Objects.nonNull(json)) { return JSONB.fromJson(json.toString(), valueClass); } return null; }
@Override public T set(int i, T t) { requireNonNull(t, "object is required"); JsonObject json = arrayList.set(i, JsonObjectCouchbaseUtil.toJson(JSONB, t)); if (Objects.nonNull(json)) { return JSONB.fromJson(json.toString(), clazz); } return null; }