Giter Club home page Giter Club logo

jackson-datatypes-collections's Introduction

Overview

This is a multi-module umbrella project for various Jackson Datatype modules to support 3rd party Collection libraries.

Currently included are:

License

All modules are licensed under Apache License 2.0.

Build Status

Build Status

Usage, general

Maven dependencies

To use these format backends Maven-based projects, use following dependency:

<dependency>
  <groupId>com.fasterxml.jackson.datatype</groupId>
  <artifactId>jackson-datatype-[COLLECTION]</artifactId>
  <version>2.13.3</version>
</dependency>

where COLLECTION would be one of guava, hppc, pcollections, or eclipse-collections (replace version with the latest available).

You may also use jackson-bom for defining consistent sets of versions of various Jackson components.

NOTE! Parent pom itself only specifies defaults to individual modules but DOES NOT include them, so you CAN NOT just add dependency to jackson-datatypes-collections. Individual datatype modules need to be included explicitly (or via some other pom that depends on them).

Registration with ObjectMapper

Like all standard Jackson modules (libraries that implement Module interface), registration for Collections datatypes is done using one of 2 mechanisms:

ObjectMapper mapper;

// New; 2.10.x / 3.0:
mapper = JsonMapper.builder() // or mapper for other formats
    .addModule(new GuavaModule())
    .addModule(new HppcModule())
    .addModule(new PCollectionsModule())
    .build();

// Old (2.x), not available on 3.x:
mapper = new ObjectMapper() // or mapper for other formats
    .registerModule(new GuavaModule())
    .registerModule(new HppcModule())
    .registerModule(new PCollectionsModule())
    .registerModule(new EclipseCollectionsModule())
    ;

after which datatype read/write support is available for all normal Jackson operations, including support for nested types.

Usage, per-datatype

See READMEs of individual modules for datatype-specific configuration, options and so on:

Usage with Spring Boot

@Bean
public Jackson2ObjectMapperBuilderCustomizer customize()
{
    return builder -> builder.modules( new GuavaModule() );
}

jackson-datatypes-collections's People

Contributors

arthurscchan avatar cookiearoundthebend avatar cowtowncoder avatar dependabot[bot] avatar felk avatar joohyukkim avatar komamitsu avatar lokeshn avatar magical-l avatar migwel avatar mukham12 avatar nbauernfeind avatar pjfanning avatar renjanmenon avatar yawkat avatar yeikel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jackson-datatypes-collections's Issues

Deserializing ImmutableMap<String,Double> fails

when trying to deserialize, let's say {"value":3.0}
it throws this exception
Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize Map key of type java.lang.Double from String "value": not a valid representation, problem: (java.lang.NumberFormatException) For input string: "value" 2019-09-26T15:57:49.276742+00:00 app[web.1]: at [Source: de.undercouch.bson4jackson.io.LittleEndianInputStream@54815ea6; pos: 6004] (through blablabla) 2019-09-26T15:57:49.276744+00:00 app[web.1]: at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67) 2019-09-26T15:57:49.276750+00:00 app[web.1]: at com.fasterxml.jackson.databind.DeserializationContext.weirdKeyException(DeserializationContext.java:1528) 2019-09-26T15:57:49.276752+00:00 app[web.1]: at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdKey(DeserializationContext.java:867) 2019-09-26T15:57:49.276755+00:00 app[web.1]: at com.fasterxml.jackson.databind.deser.std.StdKeyDeserializer.deserializeKey(StdKeyDeserializer.java:133) 2019-09-26T15:57:49.276759+00:00 app[web.1]: at com.fasterxml.jackson.datatype.eclipsecollections.deser.map.RefKeyHandler.key(RefKeyHandler.java:34) 2019-09-26T15:57:49.276770+00:00 app[web.1]: at com.fasterxml.jackson.datatype.eclipsecollections.deser.map.TypeHandlerPair$1.add(TypeHandlerPair.java:188) 2019-09-26T15:57:49.276775+00:00 app[web.1]: at com.fasterxml.jackson.datatype.eclipsecollections.deser.map.TypeHandlerPair$1.add(TypeHandlerPair.java:166) 2019-09-26T15:57:49.276798+00:00 app[web.1]: at com.fasterxml.jackson.datatype.eclipsecollections.deser.map.EclipseMapDeserializers$Entry$DeserializerImpl.deserializeEntry(EclipseMapDeserializers.java:311)

I think it may be somehow mixing V deserializer with K deserializer

Support for fastutil collections

It would be nice to support fastutil collection
The previous discussion: https://markmail.org/message/anwbtpgbvwh4ox4v#query:+page:1+mid:xqwwbpgh2ul46nst+state:results

I could do this by copy pasting https://github.com/FasterXML/jackson-datatypes-collections/tree/master/hppc and some parts from https://github.com/FasterXML/jackson-datatypes-collections/tree/master/eclipse-collections very literally, but maybe it's time to do some refactoring and introduce basic primitive collection serialization types for all primitive collection libraries, which specific libraries could subclass trivially?

A shared utility to test collection types

It would be nice if there was a shared utility to test the dark corners of ser/deser implementation for proper collection types (i. e. extending either Collection or Map):

  • Tricky (perhaps, recursive) TypeReferences as contained types
  • Contained types specified in a non-standard way, e. g. via annotation
  • Heterogeneous values
  • Raw collection serialization / deserialization (no generics)

The idea is to actually put the logic of ContainerSerializer under test.

This common utility could be reused for testing core JDK Map/List/Set serializers/deserializers, as well as Guava collections, Eclipse Collections' reference collections, and fastutil's Object collections.

Support for Guava 29?

jackson-datatype-guava cannot be used with Guava >= 28.0.0 in OSGI.

Is there a reason for this restriction? If not, can we please lift it?

I'll submit a PR if that'll help...

Guava version out of date

Hello my dears, was wondering why is guava module still dependant on guava 18?

Guava is currently at 23.3, this causes problems with other libraries that do require younger things. For example com.google.common.reflect.TypeToken.isAssignableFrom(TypeToken<?> type) is no longer there since version 20.

Drop support for Guava v10 - v13 to simplify `RangeFactory`

As support is added for newer Guava versions, retaining backwards compatibility with oldest versions is becoming more difficult, and it is not guaranteed there is actual compatibility.
Due to this, and complexity of RangeFactory (to try to support Guava versions down to v10), let's simplify RangeFactory by only using methods added in Guava v14.

This affects Jackson 2.10 and later; older versions up to 2.9.x will support older Guava versions.

Unreliable test for `eclipse collections`: `DeserializerTest.pairTyped()` sometimes fails

So, not sure if this is something I have caused, but one test in DeserializerTest seems to occasional fail (on JDK 8 at lest), as serialization order of one and two sometimes change.
I didn't dig deep, but maybe it is just that ObjectXxxPair entries are serialized as POJOs in which case order is arbitrary (and so test should be made more robust not to assume ordering).

If so, one thing that would be nice, if practical, would be to register explicit serializer that would serialize entries in order: partly for more stable output, but partly since it could be made more efficient (direct accessors, writes). If so, test could remain as is.
But I don't know if writing such serializer is practical if all types are generated: probably depends on how practical it'd be to auto-generate serializers.

SetMultimap should be deserialized to a LinkedHashMultimap by default

Currently, when deserializing to a field declared simply as a SetMultimap, a HashMultimap is used as the implementation. This is at odds with Jackson's default behavior for normal Maps where a LinkedHashMap is used to preserve the ordering present in the JSON. It seems like the Guava module should analogously use LinkedHashMultimap as the default SetMultimap implementation.

Null value handling not supported for `Optional` within `Multimap`

I'm using jackson, jackson-data-type-jdk8, and jackson-datatype-guava at version 2.8.8

It looks like nulls in my JSON object are being deserialized as null instead of Optional.empty().

I wrote a little test that shows what's happening:

@Test
    public void testNullDeserialization() throws JsonParseException, JsonMappingException, IOException {
        ObjectMapper objectMapper = new ObjectMapper()
            .registerModule(new GuavaModule());
        String json = "{\"a\" : [5.0, null, 6.0]}";
        ListMultimap<String, Optional<Double>> obj = objectMapper.readValue(
            json, 
            new TypeReference<ListMultimap<String, Optional<Double>>>() {});
        assertThat(
            obj, 
            is(ImmutableListMultimap.of(
                "a", Optional.of(5.0), 
                "a", Optional.empty(), 
                "a", Optional.of(6.0))));
    }

The output of the junit test is:

java.lang.AssertionError:
Expected: is <{a=[Optional[5.0], Optional.empty, Optional[6.0]]}>
but: was <{a=[Optional[5.0], null, Optional[6.0]]}>
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:8)

Note the middle value is null instead of Optional.empty.

Looking at the code in GuavaMultimapDeserializer.java, it looks like line 161 can be replaced with

value = elementDeserializer.getNullValue(ctxt);

Or maybe I'm just missing something?

PrimitiveRefMapSerializer and RefPrimitiveMapSerializer don't extend ContainerSerializer

ContainerSerializer (a class in jackson-databind) includes some non-trivial machinery which may change in any version of Jackson. PrimitiveRefMapSerializer and RefPrimitiveMapSerializer (in primitive_collections_base) duplicate some parts of that logic (and I'm not sure that they do it right). Therefore, I think it would be nice to refactor these classes to inherit from ContainerSerializer.

Deserialization of Guava's Optional type fails with 2.7 or later

The following code works with version 2.6, but it doesn't work with 2.7 or later.

        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new GuavaModule());
        JavaType type = mapper.getTypeFactory().constructParametrizedType(Optional.class, Optional.class, String.class);
        JsonNode jsonNode = mapper.readTree("{\"k\":\"hello\"}").get("k");
        System.out.println(String.format(">>>>> %s, %s, %s, %s", type.getClass(), type, jsonNode.getClass(), jsonNode));
        System.out.println(mapper.readValue(jsonNode.traverse(), type).toString());
>>>>> class com.fasterxml.jackson.databind.type.SimpleType, [simple type, class com.google.common.base.Optional<java.lang.String>], class com.fasterxml.jackson.databind.node.TextNode, "hello"
Exception in thread "main" com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.google.common.base.Optional` (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
 at [Source: UNKNOWN; line: -1, column: -1]
	at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
	at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1451)
	at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1027)
	at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserialize(AbstractDeserializer.java:265)
	at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:3972)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2330)

I guess this delete FasterXML/jackson-datatype-guava@85e894e#diff-49f8660695e4a3f0da79d80faf35e1e7L249 is related to it.

My questions are:

  • Is this behaviour expected?
  • Is there any workaround?

Failure of DeserializerTest.pairTyped()

In this test, the pair gets serialized with key and value reversed:

DeserializerTest.pairTyped:646 expected:<{"[one":{"@c":".DeserializerTest$B"},"two":5]}> but was:<{"[two":5,"one":{"@c":".DeserializerTest$B"}]}>

What I've found so far:

  • The test doesn't fail in debug mode (when debugged from within IDE), only in "production" mode (e. g. when Maven tests are run)
  • The test doesn't fail when it is run alone, only when it is run together with other tests (in that class and module)
  • The test doesn't fail when run on Java 8 runtime, only when run on Java 11 runtime.

Debug printing has led me (so far) to this place in POJOPropertiesCollector:
https://github.com/FasterXML/jackson-databind/blob/b12fab11ce477837be0f90d3f21348bafae9e4f5/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java#L280-L286

When the key and the value get deserialized in the wrong order, props are empty after _addFields(), but are get populated with [two, one] in _addMethods(). In normal cases, [one, two] appear in props map already after _addFields().

I had a hypothesis that custom makeProperties() logic is silently not get called in PairInstantiators. I've found that findValueInstantiator() gets called not only with ObjectIntPair (for example) as beanClass, but also with ObjectIntPairImpl. In my branch, I've tried to add the following line in PairInstantiatorsPopulator:

         PairInstantiators.add(ObjectShortPair.class, objectShortPairLambda);
+        PairInstantiators.add(ObjectShortPairImpl.class, objectShortPairLambda);

Which led to an interesting exception:

java.lang.NullPointerException
	at com.fasterxml.jackson.databind.introspect.BasicClassIntrospector._findStdTypeDesc(BasicClassIntrospector.java:226)
	at com.fasterxml.jackson.databind.introspect.BasicClassIntrospector.forClassAnnotations(BasicClassIntrospector.java:160)
	at com.fasterxml.jackson.databind.introspect.BasicClassIntrospector.forClassAnnotations(BasicClassIntrospector.java:16)
	at com.fasterxml.jackson.databind.cfg.MapperConfig.introspectClassAnnotations(MapperConfig.java:277)
	at com.fasterxml.jackson.databind.DeserializationContext.introspectClassAnnotations(DeserializationContext.java:471)
	at com.fasterxml.jackson.databind.DeserializationContext.findTypeDeserializer(DeserializationContext.java:564)
	at com.fasterxml.jackson.datatype.eclipsecollections.deser.pair.PairInstantiators.makeProperties(PairInstantiators.java:180)
	at com.fasterxml.jackson.datatype.eclipsecollections.deser.pair.PairInstantiators$4.getFromObjectArguments(PairInstantiators.java:135)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.addBeanProps(BeanDeserializerFactory.java:458)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:233)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:135)
	at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:418)
	at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:357)
	at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:271)
	at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:251)
	at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:150)
	at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:527)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase._findSubclassDeserializer(BeanDeserializerBase.java:1627)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handlePolymorphic(BeanDeserializerBase.java:1576)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:602)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1243)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:481)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:201)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2302)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:1409)
	at com.fasterxml.jackson.datatype.eclipsecollections.DeserializerTest.primitivePairs(DeserializerTest.java:626)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:383)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:344)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:125)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:417)

FYI @cowtowncoder @yawkat

Guava's RangeHelper causing NPE in PropertyNamingStrategy

I'm using Dropwizard which automatically configures Jackson at startup using the following code:

private static ObjectMapper configure(ObjectMapper mapper) {
        mapper.registerModule(new GuavaModule());
        mapper.registerModule(new GuavaExtrasModule());
        mapper.registerModule(new JodaModule());
        mapper.registerModule(new AfterburnerModule());
        mapper.registerModule(new FuzzyEnumModule());
        mapper.registerModule(new ParameterNamesModule());
        mapper.registerModule(new Jdk8Module());
        mapper.registerModule(new JavaTimeModule());
        mapper.setPropertyNamingStrategy(new AnnotationSensitivePropertyNamingStrategy());
        mapper.setSubtypeResolver(new DiscoverableSubtypeResolver());
        return mapper;
    }

Guava's RangeHelper is calling AnnotationSensitivePropertyNamingStrategy.nameForField with null value for AnnotatedField param which is resulting in an NPE.

Stacktrace:

java.lang.NullPointerException
    at io.dropwizard.jackson.AnnotationSensitivePropertyNamingStrategy.nameForField(AnnotationSensitivePropertyNamingStrategy.java:39)
    at com.fasterxml.jackson.datatype.guava.deser.util.RangeHelper._find(RangeHelper.java:43)
    at com.fasterxml.jackson.datatype.guava.deser.util.RangeHelper.getPropertyNames(RangeHelper.java:35)
    at com.fasterxml.jackson.datatype.guava.deser.RangeDeserializer.createContextual(RangeDeserializer.java:96)
    at com.fasterxml.jackson.databind.DeserializationContext.handlePrimaryContextualization(DeserializationContext.java:665)

Exception using eclipse collection serialization

the following test crashes with

java.lang.IllegalArgumentException: Null JavaType passed

at com.fasterxml.jackson.databind.deser.DeserializerCache._findCachedDeserializer(DeserializerCache.java:205)
at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:139)
at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:458)
at com.fasterxml.jackson.datatype.eclipsecollections.deser.BaseCollectionDeserializer$Ref.createContextual(BaseCollectionDeserializer.java:300)
at com.fasterxml.jackson.databind.DeserializationContext.handleSecondaryContextualization(DeserializationContext.java:696)
at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:496)
at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:4711)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4520)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3466)

=================================

@test
void testJsonSerialization() throws JsonProcessingException
{
MutableList mutableList = Lists.mutable.of("one", "two", "three");
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new EclipseCollectionsModule());

    String valueAsString = objectMapper.writeValueAsString(mutableList);
    MutableList mutableListCopy = objectMapper.readValue(valueAsString, MutableList.class);
    Verify.assertEquals(mutableList, mutableListCopy);
}

Dependency used is:

com.fasterxml.jackson.datatype jackson-datatype-eclipse-collections 2.11.2

Please, advise.
Thanks.

Guava deserialization not working when object to deserialize comes from different classloader

Hello,

I'm using retrofit2 to read json from an http page, but I get the following exception:

com.fasterxml.jackson.databind.JsonMappingException: Can not find a deserializer for non-concrete Collection type [collection type; class com.google.common.collect.ImmutableList, contains [simple type, class java.lang.String]]
at [Source: okhttp3.ResponseBody$BomAwareReader@5dd9326d; line: 1, column: 1]
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:305)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:268)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
at com.fasterxml.jackson.databind.DeserializationContext.findNonContextualValueDeserializer(DeserializationContext.java:466)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:479)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:293)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:443)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:206)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:26)
at com.fasterxml.jackson.databind.DeserializationContext.handleSecondaryContextualization(DeserializationContext.java:681)
at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:481)
at com.fasterxml.jackson.databind.ObjectReader._findRootDeserializer(ObjectReader.java:1859)
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1621)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1203)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:32)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:23)
at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:117)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:211)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)

The reason is that inside method
com.fasterxml.jackson.datatype.guava.GuavaDeserializers.findCollectionDeserializer()
the predicate ImmutableCollection.class.isAssignableFrom(raw) is returning false.
Infact raw is indeed instance of com.google.common.collect.ImmutableList but from a different classloader.

I think that raw should be obtained by:

Class<?> raw = this.getClass().getClassLoader().loadClass(type.getRawClass().getCanonicalName());

HostAndPortDeserializer rely on older version property name

HostAndPortDeserializer should use field name host instead of hostText

jackson-datatypes-collections:guava

@Override
    public HostAndPort deserialize(JsonParser p, DeserializationContext ctxt)
        throws IOException
    {
        // Need to override this method, which otherwise would work just fine,
        // since we have legacy JSON Object format to support too:
        if (p.currentToken() == JsonToken.START_OBJECT) { // old style
            JsonNode root = p.readValueAsTree();
            String host = root.path("hostText").asText();
            JsonNode n = root.get("port");
            if (n == null) {
                return HostAndPort.fromString(host);
            }
            return HostAndPort.fromParts(host, n.asInt());
        }
        return super.deserialize(p, ctxt);
    }

Guava

  /**
   * Returns the portion of this {@code HostAndPort} instance that should represent the hostname or
   * IPv4/IPv6 literal.
   *
   * <p>A successful parse does not imply any degree of sanity in this field. For additional
   * validation, see the {@link HostSpecifier} class.
   *
   * @since 20.0 (since 10.0 as {@code getHostText})
   */
  public String getHost() {
    return host;
  }

reference to Module is ambiguous when compiling GuavaModule

Vanilla jackson-datatypes-collections code fails when running tests:

cd guava
mvn test

Fails with:

ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project jackson-datatype-guava: Compilation failure: Compilation failure:
[ERROR] /Users/ernestoalvarado/eclipse-workspace/jackson-datatypes-collections/guava/src/main/java/com/fasterxml/jackson/datatype/guava/GuavaModule.java:[25,34] reference to Module is ambiguous
[ERROR]   both class com.fasterxml.jackson.databind.Module in com.fasterxml.jackson.databind and class java.lang.Module in java.lang match

Using jdk :

$ java -version
java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

No JAR in maven central release

Hi,
I want to use the lib, but there are no JAR in the maven central releases...
Is it possible to add them in the future releases.
Thanks

Range property name (de)serialisation doesn't respect property naming strategy

Field names in the Guava Range<T> are serialised and deserialised with the hard coded values lowerEndpoint, lowerBoundType, upperEndpoint and upperBoundType:

    {
      "lowerEndpoint": 1,
      "lowerBoundType": "OPEN",
      "upperEndpoint": 10,
      "upperBoundType": "CLOSED"
    }

For consistent JSON field naming it would be nice to support other property naming strategies. For example snake case:

    {
      "lower_endpoint": 1,
      "lower_bound_type": "OPEN",
      "upper_endpoint": 10,
      "upper_bound_type": "CLOSED"
    }

Please see here for the basic idea philleonard@8a3f36f. Happy to open this as a PR and change to whatever is the correct way of formatting field names when writing them as strings.

(guava) Add deserialization support for Table<R, C, V>

(note: moved from FasterXML/jackson-datatype-guava#11)

The Guava Table<R, C, V> data structure is a convenience wrapper around a Map<R, Map<C, V>>. This form can be easily serialized and deserialized. Here's the basic code I'm using for that:

    public static class TableSerializer extends JsonSerializer<Table<?, ?, ?>> {
        @Override
        public void serialize(final Table<?, ?, ?> value, final JsonGenerator jgen, final SerializerProvider provider) throws IOException,
                    JsonProcessingException {
            jgen.writeObject(value.rowMap());
        }


        @Override
        public Class<Table<?, ?, ?>> handledType() {
            return (Class)Table.class;
        }
    } // end class TableSerializer

    public static class TableDeserializer extends JsonDeserializer<Table<?, ?, ?>> {
        @Override
        public Table<?, ?, ?> deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException {
            final ImmutableTable.Builder<Object, Object, Object> tableBuilder = ImmutableTable.builder();
            final Map<Object, Map<Object, Object>> rowMap = jp.readValueAs(Map.class);
            for (final Map.Entry<Object, Map<Object, Object>> rowEntry : rowMap.entrySet()) {
                final Object rowKey = rowEntry.getKey();
                for (final Map.Entry<Object, Object> cellEntry : rowEntry.getValue().entrySet()) {
                    final Object colKey = cellEntry.getKey();
                    final Object val = cellEntry.getValue();
                    tableBuilder.put(rowKey, colKey, val);
                }
            }
            return tableBuilder.build();
        }
    } // end class TableDeserializer

I have not tested if this correctly supports contextual keys or type (de)serialization. I looked at MultimapSerializer and MultimapDeserializer, and they are much more complicated even though a Multimap<K, V> is just a convenience wrapper around Map<K, Collection<V>>, so maybe this is too simplistic?

Notably, this implementation always deserializes to an ImmutableTable. Heuristics could be used to determine what Table implementation to reconstruct, e.g., if every row, column value is non-null, could create ArrayTable. HashBasedTable would be a good mutable default.

How to deal with different Guava version than Jackson

Hello,

I encounter an issue but I guess this is more about me being not knowledgeable enough than the library doing something wrong.

In my pom.xml I have jackson-datatypes-guava at the version 2.11.2 and Guava at version 29-jre. The issue that arises is that when I call ImmutableList.toImmutableList() I have a no such method because it picks the com.google.common.collect.ImmutableList from Guava.

Do you have an indication on how to proceed ?

Have a crash with serialize guava table(row map)

https://hastebin.com/onunuworay.js
Sometime, but not always, jackson crash my application, when he try save a Table, how can i fix it?
P.S. Offtop, but i don't know where i can ask my second question. Jackson useful with many applications? Example: My Library has one object for json(with jackson ObjectMapper) to all my projects(15 apps), and sometime jackson is work bad(can't deserialize or something, when apps starts together). Can i fix it too?

Support for Guava's `Immutable{Double,Int,Long}Array`

As of Guava 22.0 there are:

I'd be nice to add support for these types and I'm willing to help get this implemented. Before I start working on a proper PR however, I have a few questions:

  • jackson-datatype-guava 2.9.2 targets Guava 18.0. Is it okay to bump this dependency to version 22.0?
  • jackson-datatype-guava 2.9.2 targets Java 7. However, the JRE version of Guava 22.0 requires Java 8. As a work-around Guava 22.0-android can be targeted instead. Is that acceptable?
  • I have a local prototype which extends PrimitiveArrayDeserializers and delegates to PrimitiveArrayDeserializers.IntDeser (i.e. PrimitiveArrayDeserializers.forType(Integer.TYPE). The thinking here is that the deserializer then has feature parity with int[] support (Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY etc.). But due to package-visibility of IntDeser this is pretty clunky. Any advice?

Add information on guava/README on compatibility between Guava module, Guava library

One thing that commonly comes up is the question on which Guava version does jackson-datatype-guava work with: although module must specify a dependency version for Guava, this does not actually define or indicate range of versions it does work against.
(reasons for not using a range are mostly due to limitations by Maven dependency handling, possibly OSGi -- at least historically version ranges in pom.xml have not worked well... plus one can not predict compatibility against future versions anyway).

We do have some test setups that allow overriding Guava, datatype module versions, so it is possible to check out actual limits. Would be great to do that, document findings.
This for recent versions of module; say 2.9 - 2.12.

[eclipse-collection] can not deserialize concrete class instance inside nested immutable eclipse-collection

Hi, the issue is like the following:
I have a field like

@JsonProperty
  private ImmutableMap<String, ImmutableList<AbstractDownloaderConfigeration>> keyToItemsList;

where AbstractDownloaderConfigeration is declared as:

@Getter
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "_type")
@JsonSubTypes({
    @JsonSubTypes.Type(value = MetaYoutubeDlConfiguration .class, name = "type 1")
})
public abstract class AbstractDownloaderConfigeration{
   //some fields
}

and the MetaYoutubeDlConfiguration class is:

@Getter @ToString
@NoArgsConstructor(force = true, access = AccessLevel.PROTECTED)
public class MetaYoutubeDlConfiguration extends AbstractDownloaderConfigeration {
  //more fields
}

As you can see I have already properly set up the @JsonTypeInfo and @JsonSubTypes on the abstract class,
but I still got:

Exception in thread "main" com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `mikufan.cx.vocadb_pv_downloader.config.downloader.AbstractDownloaderConfigeration` (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
 at [Source: (File); line: 9, column: 7] (through reference chain: mikufan.cx.vocadb_pv_downloader.config.entity.UserConfig["downloaderConfigs"])
	at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
	at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1615)
	at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:400)
	at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1077)
	at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserialize(AbstractDeserializer.java:265)
	at com.fasterxml.jackson.datatype.eclipsecollections.deser.BaseCollectionDeserializer$Ref.add(BaseCollectionDeserializer.java:318)
	at com.fasterxml.jackson.datatype.eclipsecollections.deser.BaseCollectionDeserializer$Ref.add(BaseCollectionDeserializer.java:268)
	at com.fasterxml.jackson.datatype.eclipsecollections.deser.BaseCollectionDeserializer._deserializeContents(BaseCollectionDeserializer.java:80)
	at com.fasterxml.jackson.datatype.eclipsecollections.deser.BaseCollectionDeserializer.deserialize(BaseCollectionDeserializer.java:66)
	at com.fasterxml.jackson.datatype.eclipsecollections.deser.map.RefValueHandler.value(RefValueHandler.java:60)
	at com.fasterxml.jackson.datatype.eclipsecollections.deser.map.TypeHandlerPair$1.add(TypeHandlerPair.java:188)
	at com.fasterxml.jackson.datatype.eclipsecollections.deser.map.TypeHandlerPair$1.add(TypeHandlerPair.java:166)
	at com.fasterxml.jackson.datatype.eclipsecollections.deser.map.EclipseMapDeserializers$Entry$DeserializerImpl.deserializeEntry(EclipseMapDeserializers.java:311)
	at com.fasterxml.jackson.datatype.eclipsecollections.deser.map.EclipseMapDeserializer.deserialize(EclipseMapDeserializer.java:83)
	at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:293)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:156)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4482)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3299)
	at mikufan.cx.project_vd_common_util.io.JacksonPojoTransformer.read(JacksonPojoTransformer.java:50)
	at mikufan.cx.vocadb_pv_downloader.config.parser.ArgParser.lambda$getUserConfigOrThrow$4(ArgParser.java:125)
	at mikufan.cx.project_vd_common_util.exception.ThrowableFunction.lambda$toFunction$0(ThrowableFunction.java:23)
	at mikufan.cx.project_vd_common_util.cli.parser.ParserUtil.getOrElse(ParserUtil.java:47)
	at mikufan.cx.project_vd_common_util.cli.parser.ParserUtil.getValueOrElse(ParserUtil.java:25)
	at mikufan.cx.vocadb_pv_downloader.config.parser.ArgParser.getUserConfigOrThrow(ArgParser.java:137)
	at mikufan.cx.vocadb_pv_downloader.config.ConfigFactory.getConfig(ConfigFactory.java:35)
	at mikufan.cx.vocadb_pv_downloader.Main.main(Main.java:15)

However, if I change the type of keyToItemsList from ImmutableMap<String, ImmutableList<AbstractDownloaderConfigeration>> to ImmutableMap<String, List<AbstractDownloaderConfigeration>> (using java.util.List inside the eclipse collection map), everything works fine, even though I have used Lombok in my code

I think this is a bug in this Jackson module. So I reported here

(guava) Better multiset serialization / deserialization

(moved from FasterXML/jackson-datatype-guava#51 by @devinrsmith)

Currently, multisets' serialization size is proportional to Multiset.size() as opposed to Multiset.entrySet().size().

For example, if I have do Multiset.setCount("my_key", 1000), "my_key" is repeated 1000 times in the output. It would be much more appropriate if it behaved liked Map<String, Integer>.


I'm not familiar w/ the intricacies of jackson serialization / deserialization. I'd be pretty surprised if there is widespread use of serializing Multisets (using the existing jackson library)... I would have guessed a lot of other people would be bringing up this exact issue if they were using it. Does jackson ever create hard-breaks in backwards compatibility?

[guava] Java Serialization Support

Core Jackson has support for serializing ObjectMappers since 2.1. But if you add in the guava module, java serialization no longer works because the guava extensions are not serializable.

`Range` deserialization fails when `ObjectMapper` has default typing enabled

If i have an ObjectMapper like the following

final ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new GuavaModule());
mapper.setDefaultTyping(new ObjectMapper.DefaultTypeResolverBuilder(ObjectMapper.DefaultTyping.NON_FINAL));

And then I try to serialize a Guava Range into an String, it becomes

{
        "lowerEndpoint": 1,
        "lowerBoundType": [
          "com.google.common.collect.BoundType",
          "CLOSED"
        ],
        "upperEndpoint": 10,
        "upperBoundType": [
          "com.google.common.collect.BoundType",
          "CLOSED"
        ]
}

Instead of the basic

    {
      "lowerEndpoint": 1,
      "lowerBoundType": "CLOSED",
      "upperEndpoint": 10,
      "upperBoundType": "CLOSED"
    }

So far, so good
But if you try to deserialized that first json.
The Range Deserializer throws an error

com.fasterxml.jackson.databind.JsonMappingException: Expecting VALUE_STRING, found START_ARRAY
	at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:270)
	at com.fasterxml.jackson.datatype.guava.deser.RangeDeserializer.expect(RangeDeserializer.java:194)
	at com.fasterxml.jackson.datatype.guava.deser.RangeDeserializer.deserializeBoundType(RangeDeserializer.java:171)

Seems that this check
https://github.com/FasterXML/jackson-datatypes-collections/blob/master/guava/src/main/java/com/fasterxml/jackson/datatype/guava/deser/RangeDeserializer.java#L175
Doesn't work very happily with ObjectMappers using "Typers"

Not entirely sure where to fix this or how to avoid this

Regarding using Typers on the mapper, it's begin used by a popular redis client lib
https://github.com/redisson/redisson

Thanks

`GuavaImmutableCollectionDeserializer` cannot deserialize an empty `Optional` from null

The following test should pass

public void testImmutableListOfOptionals() throws IOException {
	ImmutableList<OptionalInt> list = MAPPER.readValue("[1,null,3]", new TypeReference<ImmutableList<OptionalInt>>() { });
	assertEquals(3, list.size());
	assertEquals(OptionalInt.of(1), list.get(0));
	assertEquals(OptionalInt.empty(), list.get(1));
	assertEquals(OptionalInt.of(3), list.get(2));
}

See #27

[guava] `Multimap` deserializer does not honor DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY

(moved from FasterXML/jackson-datatype-guava#89 by @neilmcguigan)

Should be able to have

enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
class Foo {
    public Multimap<String,String> bar;
}

with JSON

{
  bar: "qux"
}

However, this throws exception:

JsonMappingException: Expecting START_ARRAY, found VALUE_STRING`

Please note that this works:

class Foo {
    List<String> bar;
}

with JSON:

{
  bar: "qux"
}

when

enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);

LICENSE file in .jar

Hello, We've seen a problem a few times where our systems are unable to detect the LICENSE file in the .jar files for these packages because instead of actually containing the Apache-2.0 license file and a separate NOTICE file it contains only the following, which our tools aren't able to parse (without extra code, which we're also working on).

This copy of Jackson JSON processor streaming parser/generator is licensed under the
Apache (Software) License, version 2.0 ("the License").
See the License for details about distribution rights, and the
specific rights regarding derivate works.

You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0

I wondered if your customers would be better served by including a copy of the unmodified license file (which the license itself appears to require) as LICENSE and a separate NOTICE file with your copyright statement (again as suggested by the license).

No worries if there are reasons not to do this, I just thought it would be okay to ask politely.

Guava collection deserialization failure with `Nulls.AS_EMPTY`

Wrapped Guava collections don't deserialize properly anymore. This used to work in 2.9.10 but doesn't work in 2.10.4 anymore. For example the following code fails due to com.fasterxml.jackson.databind.exc.InvalidDefinitionException:

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.guava.GuavaModule;
import com.google.common.collect.ImmutableList;

public class JacksonTest {

    private static final ObjectMapper MAPPER = new ObjectMapper()
            .registerModule(new GuavaModule())
            .setDefaultSetterInfo(JsonSetter.Value.forContentNulls(Nulls.AS_EMPTY));

    public static void main(String[] args) throws Exception {
        String json = MAPPER.writeValueAsString(new TestClass());
        MAPPER.readValue(json, TestClass.class);
    }

    public static class TestClass {
        public ImmutableList<ImmutableList<String>> lists = ImmutableList.of();
    }
}

Setting defaultSetterInfo seems to pay a meaningful role in the bug, also it happens only with Guava collections. Normal List works fine.

As a result you get:

Exception in thread "main" com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot create empty instance of [collection type; class com.google.common.collect.ImmutableList, contains [simple type, class java.lang.String]], no default Creator
 at [Source: (String)"{"lists":[]}"; line: 1, column: 1]
	at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
	at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1592)
	at com.fasterxml.jackson.databind.deser.std.ContainerDeserializerBase.getEmptyValue(ContainerDeserializerBase.java:149)
	at com.fasterxml.jackson.databind.deser.std.StdDeserializer._findNullProvider(StdDeserializer.java:1167)
	at com.fasterxml.jackson.databind.deser.std.StdDeserializer.findContentNullProvider(StdDeserializer.java:1115)
	at com.fasterxml.jackson.datatype.guava.deser.GuavaCollectionDeserializer.createContextual(GuavaCollectionDeserializer.java:80)
	at com.fasterxml.jackson.databind.DeserializationContext.handlePrimaryContextualization(DeserializationContext.java:653)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:502)
	at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:293)
	at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
	at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
	at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:479)
	at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:4405)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4214)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3214)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3182)
	at JacksonTest.main(JacksonTest.java:18)

Full example code is available at https://github.com/ari-talja-rovio/jackson-example

guava tests failing with jdk8

The test jackson-datatypes-collections/guava/src/test/java/com/fasterxml/jackson/datatype/guava/TestMultimaps.java fails with:

jackson-datatypes-collections/guava/src/test/java/com/fasterxml/jackson/datatype/guava/TestMultimaps.java:[134,37] no suitable method found for readValue(java.lang.String,<anonymous com.fas
terxml.jackson.core.type.TypeReference<com.google.common.collect.TreeMultimap<java.lang.String,java.lang.Boolean>>>)

Is this test outdated?

Bug deserializing Eclipse Collection's MutableMap.

First off, thank you very much to @yawkat and @cowtowncoder for adding support for Eclipse Collections. I'm trying to change some usages of Map to MutableMap in my DTOs and running into an exception.

I've included two tests below to show the issue. I'm not sure if it's the same as #40.

The java.util.Map test passes with no output. The MutableMap test throws:

com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize Map key of type `java.lang.Boolean` from String "trueKey": not a valid representation, problem: (com.fasterxml.jackson.databind.exc.InvalidFormatException) Cannot deserialize Map key of type `java.lang.Boolean` from String "trueKey": value not 'true' or 'false'
 at [Source: (String)"{
  "string": "string",
  "map": {
    "trueKey": true,
    "falseKey": false
  }
}
"; line: 4, column: 16]
 at [Source: (String)"{
  "string": "string",
  "map": {
    "trueKey": true,
    "falseKey": false
  }
}
"; line: 4, column: 16] (through reference chain: com.example.JacksonEclipseCollectionsTest$HasMutableMap["map"])

In JacksonEclipseCollectionsTest.java:

package com.example;

import java.io.IOException;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.eclipsecollections.EclipseCollectionsModule;
import org.eclipse.collections.api.map.MutableMap;
import org.junit.Test;

public class JacksonEclipseCollectionsTest
{
    //language=JSON
    private static final String JSON = ""
            + "{\n"
            + "  \"string\": \"string\",\n"
            + "  \"map\": {\n"
            + "    \"trueKey\": true,\n"
            + "    \"falseKey\": false\n"
            + "  }\n"
            + "}\n";

    private final ObjectMapper objectMapper = new ObjectMapper()
            .registerModule(new EclipseCollectionsModule());

    public static final class HasMutableMap
    {
        @JsonCreator
        public HasMutableMap(
                @JsonProperty("string") String string,
                @JsonProperty("map") MutableMap<String, Boolean> map) {}
    }

    public static final class HasRegularMap
    {
        @JsonCreator
        public HasRegularMap(
                @JsonProperty("string") String string,
                @JsonProperty("map") Map<String, Boolean> map) {}
    }

    @Test
    public void testMutableMap() throws IOException
    {
        this.objectMapper.readValue(JSON, HasMutableMap.class);
    }

    @Test
    public void testRegularMap() throws IOException
    {
        this.objectMapper.readValue(JSON, HasRegularMap.class);
    }
}

Document how to generate module files using moditect

Working on this PR: #51, I'm having trouble generating module-info.java for the new module (primitive-collections-base). It would be nice if this repository contained some dev documentation about how to initially generate & update module-infos for new and existing modules in this project.

(regression) Failure to resolve `TypeDeserializer` in 3.0 for `PairInstantiators`

Looks like I managed to create bit of conundrum wrt parameter(s) passed to ValueInstantiator.getFromObjectArguments() in 3.0. At some point I had change config argument to context, but this has its problems as per:

FasterXML/jackson-databind#2748

and conceptually I think it might be wrong way to go about it. So I reverted the change.
Which leads us to eclipse-collections where there was minor usage -- due to sort of related 3.0 change that made TypeDeserializer only accessible through DeserializationContext, not just DeserializationConfig.

I will need to figure out how to fix this: my initial thinking is that maybe there is need for contextualization call of some sort... but need to think about it bit more first.
Anyway. This issue is a reminder that now there is 1 test failure for 3.0 eclipse-collections, to be fixed.

(guava) Multimap serializer doesn't work with non-String keys, even if it seems like they should.

(moved from FasterXML/jackson-datatype-guava#13 by @stevenschlansker )

Serializing a Multimap fails if K is any non-String type, even if intuitively it should work (e.g. K is a string-like type such as Enum, or K has an @JsonValue annotation).

I couldn't figure out how this is supposed to work, so I have included failing test cases for both the 1.9 branch and 2.x branch and hope that someone else who knows more about how Jackson's typing works can help out.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.