FamilySearch/gedcomx-java

Integrating Gedcomx into FasterXML project

Closed this issue · 2 comments

I have a FasterXML project that requires me to use the Gedcomx model library. This is my POM:

	<dependency>
		<groupId>org.gedcomx</groupId>
		<artifactId>gedcomx-model</artifactId>
		<version>2.9.0</version>
	</dependency>

However, when I try to deserialize data, I get an error which I believe is related to conflicts between the Codehaus and FasterXML. What am I missing?

Failed to evaluate Jackson deserialization for type [[simple type, class org.gedcomx.Gedcomx]]: com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "name": org.gedcomx.common.Qualifier#setName(1 params) vs org.gedcomx.common.Qualifier#setName(1 params)

Just to make sure we're on the same page: "FasterXML" is the name of the company that creates Jackson, which is the JSON parsing library. There are two versions of Jackson: Jackson 1 and Jackson 2. When you say "FasterXML", I think what you're really saying is "Jackson 2" because Jackson 1 was under the "org.codehaus.jackson" package and Jackson 2 is under the "com.fasterxml.jackson" package.

The GEDCOM X JSON spec requires some special handling. You need to configure your ObjectMapper with the org.gedcomx.rt.json.GedcomJacksonModule:

ObjectMapper mapper = ...;
mapper.registerModule(new GedcomJacksonModule());

Or just use the utility method in GedcomJacksonModule:

ObjectMapper mapper = GedcomJacksonModule.createObjectMapper();

Right, I get the Jackson 2 vs. Jackson 1 from other libraries I've worked with. I didn't know about the need for the alternate GedcomJacksonModule. I'll give that a try. Thanks!