com.guicedee.services.hibernate.StringToPropertiesDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
JPMS Module-Info's for a few of the Jakarta Libraries just until they add them in themselves
package com.guicedee.services.hibernate;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import java.io.IOException;
import java.util.Properties;
public class StringToPropertiesDeserializer extends JsonDeserializer {
@Override
public Properties deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
Properties props = new Properties();
JsonNode node = p.readValueAsTree();
node.fields().forEachRemaining(a->{
ArrayNode node1 = (ArrayNode) a.getValue();
node1.elements().forEachRemaining(b->{
String key = b.findValue("name").asText();
String val = b.findValue("value").asText();
props.put(key, val);
});
});
return props;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy