Comments (8)
I am positively considering adding this feature.
I have made a prototype at kogera
for policy consideration.
ProjectMapK/jackson-module-kogera#224
It will be basically the same usability as deserialization of value class
.
The difference is that the wrapped type is also deserialized by the context-accessible KeyDeserializer
.
However, I am busy and sick, so it may take some time until I can merge it into kotlin-module
.
I hope to complete it by May at the latest.
@cowtowncoder
I have two questions about Jackson
functionality.
I don't believe there is a JsonCreator
like feature used to deserialize keys, is this correct?
Also, are there any caveats about searching for another KeyDeserializer
from a KeyDeserializer
?
https://github.com/ProjectMapK/jackson-module-kogera/pull/224/files#diff-b03a6f91081da3aa22c53b161b0a2f6f1a0cf4ba318329907046b5f5335b17c8R72-R73
I am assuming that this is a very limited edge case, but I am assuming that there are nested types that require a special deserialization method.
https://github.com/ProjectMapK/jackson-module-kogera/pull/224/files#diff-11c6e0b61e487e3914690655846ffd6100b92c022082ea610bb8d086f7be18dcR87-R116
from jackson-module-kotlin.
@junkdog
A generic key deserializer for the value class
is not currently provided by jackosn-module-kotlin
.
This means that Cannot find a (Map) Key deserializer
should be thrown as for other classes.
It is still possible to deserialize a value class
as a Map
key by registering the appropriate key deserializer.
For these reasons, I interpret this as a feature request.
from jackson-module-kotlin.
Just to clarify, previous versions of jackson don't exhibit errors when using value classes as keys in maps. As such, I think this should be labeled as a bug and not an enhancement.
from jackson-module-kotlin.
Maybe the difference here is wrt serialization (where "value.toString()" is used for "unknown" types) vs deserialization (where exception will be thrown)?
Handling differs quite a bit b/w reading (deser) and writing (ser).
from jackson-module-kotlin.
@cowtowncoder I have two questions about
Jackson
functionality.I don't believe there is a
JsonCreator
like feature used to deserialize keys, is this correct?
No I don't think so; except for @JsonKey
annotation... use of which might work via custom AnnotationIntrospector
.
Also, are there any caveats about searching for another
KeyDeserializer
from aKeyDeserializer
? https://github.com/ProjectMapK/jackson-module-kogera/pull/224/files#diff-b03a6f91081da3aa22c53b161b0a2f6f1a0cf4ba318329907046b5f5335b17c8R72-R73
Not sure; in general ideally would be resolved earlier and not during reading (in fact, it really should be done during construction/resolution for deserialization; sometimes not doable for serialization). But other than that I suspect it should be fine.
from jackson-module-kotlin.
except for @jsonkey annotation... use of which might work via custom AnnotationIntrospector.
Is this not a function for @JsonValue
?
I wanted to make sure there is no such thing as @JsonKeyCreator
.
from jackson-module-kotlin.
I will not implement this feature in kotlin-module
until the following issues are resolved, as it will override custom implementations defined by the user.
FasterXML/jackson-databind#4444
I am unable to work on a fix as my busy state has become rather worse.
If anyone has a strong desire for this feature, I would appreciate it if you could fix it.
from jackson-module-kotlin.
Is this not a function for @JsonValue?
I wanted to make sure there is no such thing as @JsonKeyCreator
No, as name implies, it is for JSON values -- keys are specifically separate thing (from Jackson perspective), key names for java.util.Map
s bound from JSON Object property names (vs property values). Part of the problem is that Property names are exposed as JsonToken.FIELD_NAME
so regular value JsonDeserializer
cannot be used; and thereby there is separate KeyDeserializer
.
At any rate, handling is quite separate and as such I don't see how @JsonValue
could be used outside limited cases (like with maybe Enum
type)
But there are also other relevant annotations: @JsonDeserialize(keyUsing = <KeyDeserializer class>
and @JsonSerialize(keyUsing = <key serializer class>
that can be used on class to mark handler(s).
from jackson-module-kotlin.
Related Issues (20)
- Deserialization using default arguments fails when the creator parameter contains `value class` and the number is a multiple of 32.
- Serialization in Ktor project fails HOT 2
- Polymorphic sealed class missing type information
- mapper.updateValue allows to set fields to null which are not nullable HOT 1
- Incosistent behaviour with a single field
- Field proliferation bug when using ObjectMapper in Kotlin HOT 2
- @JsonProperty ignored when serialising Kotlin @JvmRecord in 2.16.X HOT 3
- Excessive memory usage when using KotlinModule with Kotlin data class HOT 2
- `NoSuchMethodError` for `com.fasterxml.jackson.module.kotlin.jacksonObjectMapper` after upgrading to 2.17.0 HOT 12
- Can't compute ClassId for primitive type: int HOT 5
- Create 2.18 branch HOT 1
- How to disable the feature who rename a primitive boolean "isXXX" to "XXX" HOT 1
- Property enabledSingletonSupport - deprecated but with wrong template HOT 2
- Field with value class typ ignoring JsonProperty binding HOT 1
- Custom deserializer of inlined value class (with delegate) HOT 3
- 2.18 build on JDK 8 fails CI HOT 2
- Kotlin Module interferes with Java record deserialization HOT 4
- Missing classes error using AGP 8 R8 shrinker HOT 1
- Boolean property setter is skipped if name isX prefixed HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jackson-module-kotlin.