cz.cvut.kbss.jsonld.jackson.deserialization.JacksonJsonLdDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jb4jsonld-jackson Show documentation
Show all versions of jb4jsonld-jackson Show documentation
JB4JSON-LD integration for Jackson.
/**
* Copyright (C) 2022 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package cz.cvut.kbss.jsonld.jackson.deserialization;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.deser.std.DelegatingDeserializer;
import com.fasterxml.jackson.databind.jsontype.TypeDeserializer;
import com.github.jsonldjava.core.JsonLdError;
import com.github.jsonldjava.core.JsonLdProcessor;
import cz.cvut.kbss.jsonld.ConfigParam;
import cz.cvut.kbss.jsonld.Configuration;
import cz.cvut.kbss.jsonld.deserialization.JsonLdDeserializer;
import cz.cvut.kbss.jsonld.deserialization.ValueDeserializer;
import cz.cvut.kbss.jsonld.exception.JsonLdDeserializationException;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public class JacksonJsonLdDeserializer extends DelegatingDeserializer {
private final ObjectMapper mapper = new ObjectMapper();
private final Configuration configuration;
private final Class> resultType;
private final Map, ValueDeserializer>> commonDeserializers;
public JacksonJsonLdDeserializer(JsonDeserializer> delegatee, Class> resultType, Configuration configuration,
Map, ValueDeserializer>> commonDeserializers) {
super(delegatee);
this.resultType = resultType;
this.configuration = configuration;
this.commonDeserializers = commonDeserializers;
}
@Override
protected JsonDeserializer> newDelegatingInstance(JsonDeserializer> newDelegatee) {
return new JacksonJsonLdDeserializer(newDelegatee, resultType, configuration, commonDeserializers);
}
@Override
public Object deserialize(JsonParser jp, DeserializationContext ctx) throws IOException {
try {
final Object input = parseJsonObject(jp);
final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy