![JAR search and dependency download from the Maven repository](/logo.png)
com.sportdataapi.util.ResponseQueryDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sportdata-api-client Show documentation
Show all versions of sportdata-api-client Show documentation
A simple sportdataapi.com client.
The newest version!
package com.sportdataapi.util;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
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;
/**
* Helps Jackson to deserialize the query attribute in a response.
* @author ralph
*
*/
public class ResponseQueryDeserializer extends JsonDeserializer {
/**
* Constructor.
*/
public ResponseQueryDeserializer() {
}
/**
* {@inheritDoc}
*/
@Override
public ResponseQuery deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
Map values = new HashMap<>();
ResponseQuery rc = new ResponseQuery();
JsonNode node = p.readValueAsTree();
if (!node.isArray()) {
Iterator> i = node.fields();
while (i.hasNext()) {
Map.Entry entry = i.next();
String name = entry.getKey();
String value = entry.getValue().asText();
values.put(name, value);
}
}
rc.setQueryValues(values);
return rc;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy