Disable Jackson autodetect and annotate remaining classes

This commit is contained in:
Antonin Delpeuch 2018-09-30 10:50:46 +01:00
parent bb0b351cef
commit b6a724b429
4 changed files with 22 additions and 0 deletions

View File

@ -39,6 +39,8 @@ import java.util.Properties;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONWriter; import org.json.JSONWriter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.refine.Jsonizable; import com.google.refine.Jsonizable;
/** /**
@ -50,6 +52,7 @@ import com.google.refine.Jsonizable;
public class EvalError implements Serializable, Jsonizable { public class EvalError implements Serializable, Jsonizable {
private static final long serialVersionUID = -102681220092874080L; private static final long serialVersionUID = -102681220092874080L;
@JsonProperty("message")
final public String message; final public String message;
public EvalError(String message) { public EvalError(String message) {
@ -75,5 +78,10 @@ public class EvalError implements Serializable, Jsonizable {
writer.key("message"); writer.value(message); writer.key("message"); writer.value(message);
writer.endObject(); writer.endObject();
} }
@JsonProperty("type")
public String getType() {
return "error";
}
} }

View File

@ -40,6 +40,8 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.json.JSONWriter; import org.json.JSONWriter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.refine.Jsonizable; import com.google.refine.Jsonizable;
import com.google.refine.expr.ExpressionUtils; import com.google.refine.expr.ExpressionUtils;
import com.google.refine.model.Recon.Judgment; import com.google.refine.model.Recon.Judgment;
@ -53,8 +55,11 @@ public class ReconStats implements Jsonizable {
); );
} }
@JsonProperty("nonBlanks")
final public int nonBlanks; final public int nonBlanks;
@JsonProperty("newTopics")
final public int newTopics; final public int newTopics;
@JsonProperty("matchedTopics")
final public int matchedTopics; final public int matchedTopics;
public ReconStats(int nonBlanks, int newTopics, int matchedTopics) { public ReconStats(int nonBlanks, int newTopics, int matchedTopics) {

View File

@ -39,6 +39,8 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.json.JSONWriter; import org.json.JSONWriter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.refine.Jsonizable; import com.google.refine.Jsonizable;
/** /**
@ -47,7 +49,9 @@ import com.google.refine.Jsonizable;
* store the (expected) types of new columns. * store the (expected) types of new columns.
*/ */
public class ReconType implements Jsonizable { public class ReconType implements Jsonizable {
@JsonProperty("id")
public String id; public String id;
@JsonProperty("name")
public String name; public String name;
public ReconType(String id, String name) { public ReconType(String id, String name) {

View File

@ -59,6 +59,9 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.json.JSONTokener; import org.json.JSONTokener;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.module.SimpleModule;
@ -74,6 +77,8 @@ public class ParsingUtilities {
module.addSerializer(double.class, new SerializationFilters.DoubleSerializer()); module.addSerializer(double.class, new SerializationFilters.DoubleSerializer());
module.addSerializer(OffsetDateTime.class, new SerializationFilters.DateSerializer()); module.addSerializer(OffsetDateTime.class, new SerializationFilters.DateSerializer());
mapper.registerModule(module); mapper.registerModule(module);
mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
} }
public static final FilterProvider defaultFilters = new SimpleFilterProvider() public static final FilterProvider defaultFilters = new SimpleFilterProvider()