uk.co.mruoc.jsonapi.ApiDocumentDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jackson-json-api Show documentation
Show all versions of jackson-json-api Show documentation
Library containing jackson module and classes to help building APIs that follow the json api spec in Java
package uk.co.mruoc.jsonapi;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import java.io.IOException;
public class ApiDocumentDeserializer extends StdDeserializer {
private final ApiDocumentFactory documentFactory;
public ApiDocumentDeserializer(final Class type,
final ApiDocumentFactory documentFactory) {
super(type);
this.documentFactory = documentFactory;
}
@Override
public D deserialize(final JsonParser parser, final DeserializationContext context) throws IOException {
final JsonNode rootNode = parser.getCodec().readTree(parser);
final JsonNode dataNode = rootNode.get("data");
final ApiDataDocumentRequest request = ApiDataDocumentRequest.builder()
.parser(parser)
.context(context)
.rootNode(rootNode)
.dataNode(dataNode)
.build();
return documentFactory.build(request);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy