Search in sources :

Example 1 with JSONB

use of org.jooq.JSONB in project jOOQ by jOOQ.

the class AbstractResult method formatJSON0.

private static final void formatJSON0(Object value, Writer writer, JSONFormat format) throws java.io.IOException {
    // [#2741] TODO: This logic will be externalised in new SPI
    if (value instanceof byte[]) {
        byte[] a = (byte[]) value;
        JSONValue.writeJSONString(DatatypeConverter.printBase64Binary(a), writer);
    } else // [#6563] Arrays can be serialised natively in JSON
    if (value instanceof Object[]) {
        Object[] array = (Object[]) value;
        writer.append('[');
        for (int i = 0; i < array.length; i++) {
            if (i > 0)
                writer.append(',');
            formatJSON0(array[i], writer, format);
        }
        writer.append(']');
    } else // [#7782] Nested records should generate nested JSON data structures
    if (value instanceof Formattable) {
        Formattable f = (Formattable) value;
        f.formatJSON(writer, format);
    } else if (value instanceof JSON && !format.quoteNested()) {
        writer.write(((JSON) value).data());
    } else if (value instanceof JSONB && !format.quoteNested()) {
        writer.write(((JSONB) value).data());
    } else {
        JSONValue.writeJSONString(value, writer);
    }
}
Also used : JSONB(org.jooq.JSONB) JSON(org.jooq.JSON) Formattable(org.jooq.Formattable)

Aggregations

Formattable (org.jooq.Formattable)1 JSON (org.jooq.JSON)1 JSONB (org.jooq.JSONB)1