use of org.opensearch.client.json.JsonpSerializable in project opensearch-java by opensearch-project.
the class TermsQueryField method serialize.
@Override
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
if (_value instanceof JsonpSerializable) {
((JsonpSerializable) _value).serialize(generator, mapper);
} else {
switch(_kind) {
case Value:
generator.writeStartArray();
for (FieldValue item0 : ((List<FieldValue>) this._value)) {
item0.serialize(generator, mapper);
}
generator.writeEnd();
break;
}
}
}
use of org.opensearch.client.json.JsonpSerializable in project opensearch-java by opensearch-project.
the class JsonbJsonpMapper method serialize.
@Override
public <T> void serialize(T value, JsonGenerator generator) {
if (value instanceof JsonpSerializable) {
((JsonpSerializable) value).serialize(generator, this);
return;
}
// JSON-B doesn't offer a way to serialize to a JSON generator, so we have to roundtrip via a string representation.
CharArrayWriter caw = new CharArrayWriter();
jsonb.toJson(value, caw);
CharArrayReader car = new CharArrayReader(caw.toCharArray());
JsonParser parser = jsonProvider.createParser(car);
transferAll(parser, generator);
}
Aggregations