Jackson deserialization for ReconType
This commit is contained in:
parent
0dae0811b0
commit
599edd374f
@ -33,10 +33,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
package com.google.refine.model;
|
package com.google.refine.model;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import com.google.refine.util.ParsingUtilities;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This represents a type from the reconciliation
|
* This represents a type from the reconciliation
|
||||||
@ -49,20 +52,17 @@ public class ReconType {
|
|||||||
@JsonProperty("name")
|
@JsonProperty("name")
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
public ReconType(String id, String name) {
|
@JsonCreator
|
||||||
|
public ReconType(
|
||||||
|
@JsonProperty("id")
|
||||||
|
String id,
|
||||||
|
@JsonProperty("name")
|
||||||
|
String name) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public ReconType load(JSONObject obj) throws Exception {
|
static public ReconType load(String json) throws IOException {
|
||||||
if (obj == null) {
|
return ParsingUtilities.mapper.readValue(json, ReconType.class);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReconType type = new ReconType(
|
|
||||||
obj.getString("id"),
|
|
||||||
obj.getString("name")
|
|
||||||
);
|
|
||||||
return type;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user