use of org.jooq.JSONEntry in project jOOQ by jOOQ.
the class DefaultParseContext method parseFieldJSONLiteralIf.
private final Field<?> parseFieldJSONLiteralIf() {
if (parseKeywordIf("JSON")) {
if (parseIf('{')) {
if (parseIf('}'))
return jsonObject();
List<JSONEntry<?>> entries = parseList(',', ctx -> {
Field key = parseField();
parse(':');
return key(key).value(parseField());
});
parse('}');
return jsonObject(entries);
} else if (parseIf('[')) {
if (parseIf(']'))
return jsonArray();
List<Field<?>> fields = parseList(',', c -> parseField());
parse(']');
return jsonArray(fields);
} else
throw expected("[", "{");
}
return null;
}
use of org.jooq.JSONEntry in project jOOQ by jOOQ.
the class DefaultParseContext method parseFieldJSONObjectConstructorIf.
private final Field<?> parseFieldJSONObjectConstructorIf() {
boolean jsonb = false;
if (parseFunctionNameIf("JSON_OBJECT", "JSON_BUILD_OBJECT") || (jsonb = parseFunctionNameIf("JSONB_BUILD_OBJECT"))) {
parse('(');
if (parseIf(')'))
return jsonb ? jsonbObject() : jsonObject();
List<JSONEntry<?>> result;
JSONOnNull onNull = parseJSONNullTypeIf();
DataType<?> returning = parseJSONReturningIf();
if (onNull == null && returning == null) {
result = parseList(',', c -> parseJSONEntry());
onNull = parseJSONNullTypeIf();
returning = parseJSONReturningIf();
} else
result = new ArrayList<>();
parse(')');
JSONObjectNullStep<?> s1 = jsonb ? jsonbObject(result) : jsonObject(result);
JSONObjectReturningStep<?> s2 = onNull == NULL_ON_NULL ? s1.nullOnNull() : onNull == ABSENT_ON_NULL ? s1.absentOnNull() : s1;
return returning == null ? s2 : s2.returning(returning);
}
return null;
}
Aggregations