use of org.eclipse.yasson.internal.JsonbParser in project styx by petafuel.
the class HrefTypeDeserializer method deserialize.
@Override
public Links.Href deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
JsonValue parsedValue = parser.getValue();
Links.Href href = new Links.Href();
if (parsedValue instanceof JsonObject) {
try (Jsonb jsonb = JsonbBuilder.create()) {
href = jsonb.fromJson(parsedValue.toString(), Links.Href.class);
} catch (Exception e) {
LOG.error("Error trying to deserialize Href", e);
}
} else {
LinkType linkType = null;
if (parser instanceof JsonbParser) {
JsonbParser jsonbParser = (JsonbParser) parser;
linkType = LinkType.getByString(jsonbParser.getCurrentLevel().getLastKeyName());
}
href = new Links.Href(parsedValue.toString().replace("\"", ""), linkType);
}
return href;
}
Aggregations