phil-t
05/06/2022, 3:22 PM"types": {
"10003327": {
"typeNumber": 11,
"classNumber": 335,
"display": 0,
"max": "2000",
"name": "My type"
}
},
The number 10003327
could be different in each response. If I was to use the data classes below I think it would work only for this example, but in another response with a different number it wouldn’t work:
data class Response(
val types: NumberType
)
data class NumberType(
@JsonProperty("10003327") val typeField: Type
)
data class Type(
val typeNumber: Int,
val classNumber: Int,
val display: Int,
val max: String,
val name: String
)
Is there a way to deserialise this completely when you don’t know what the number of the field will be, maybe with another annotation?Sam
07/13/2022, 8:11 AMrrva
08/25/2022, 10:14 AMRob Elliot
10/24/2022, 10:28 AM@JsonValue
work when the property is nullable and the json has null as the value?Fredrik Rødland
10/28/2022, 10:42 AMend_exclusive
. We have clients which are not able to update kotlin as easily (apps in the wild). They now get the following error:
Unrecognized field "end_exclusive" (class kotlin.ranges.IntRange), not marked as ignorable (2 known properties: "start", "end"
Does anybody know of a nice work-around for this. we thought about implementing our own small dataclass on the serverside which adhers to the IntRange
api of kotlin <= 1.7.10, but it's seems kinda hacky...Adam Firen
11/09/2022, 6:58 PMEric
01/03/2023, 5:03 PMEric
01/11/2023, 6:57 PMapplication.yaml
? for example
spring:
jackson:
kotlin:
null-to-empty-collection: true
null-to-empty-map: true
null-is-same-as-default: true
wrongwrong
01/14/2023, 4:07 PMwrongwrong
01/21/2023, 2:15 AMkotlin-reflect
with kotlinx-metadata-jvm
would benefit jackson-module-kotlin
users on Android
, please let me know.
https://kotlinlang.slack.com/archives/C0B8M7BUY/p1674267151483919wrongwrong
03/19/2023, 3:19 PMwrongwrong
04/26/2023, 8:35 AMjackson-module-kotlin
2.15.0 has been released.
This version contains many important changes.
Feedback and bug reports are welcome.
https://github.com/FasterXML/jackson-module-kotlin/blob/7dd3c74313b6640724672262e8e0d19f0498de43/release-notes/VERSION-2.x#L23-L61
https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-kotlin/2.15.0dave08
04/27/2023, 1:27 PMdmcg
05/16/2023, 7:48 AMBrian Estrada
07/10/2023, 12:59 PMwrongwrong
07/17/2023, 4:42 AMMarcus Ilgner
07/25/2023, 1:32 PMdata class DataPoint {
@JsonFormat(
shape = JsonFormat.Shape.STRING,
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "UTC")
val time: Instant,
}
val mapper = jacksonObjectMapper()
mapper.registerModule(JavaTimeModule())
val dataPoint = DataPoint(time = Instant.parse("2001-09-09T01:46:40Z"))
val encoded = mapper.writeValueAsString(dataPoint)
assertEquals(
"{\"time\":\"2001-09-09T01:46:40Z\"}",
encoded,
)
Unfortunately the encoded value for time
looks like this an object, even though the shape was set to `STRING`:
{
"time": {
"epochSeconds": 1000000000,
"value$kotlinx_datetime": "2001-09-09T01:46:40Z",
"nanosecondsOfSecond": 0
}
}
any ideas?wrongwrong
09/02/2023, 3:31 AMwrongwrong
10/09/2023, 9:42 AMJeffrey Gulbronson
10/20/2023, 3:40 PMjackson-module-kotlin
? I’m trying to get it to deserialize results with the Elasticsearch client, and have registered the Kotlin extension with registerKotlinModule
. Unfortunately it says Cannot construct instance of Foo (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
.
When decompiling the class, it actually has two constructors (one private and public), which we’re not seeing in the data classes that do deserialize correctly (those only have one public constructor)Jeffrey Gulbronson
10/20/2023, 3:47 PMinline
class for a field of the data classJeffrey Gulbronson
10/20/2023, 3:56 PMwrongwrong
10/28/2023, 4:19 PMhenrik
11/01/2023, 4:12 PMwrongwrong
11/11/2023, 2:12 PMwrongwrong
11/20/2023, 12:23 PMwrongwrong
12/02/2023, 12:52 PMYonatan Karp-Rudin
12/11/2023, 9:13 AM1.7.x
to version 1.8.x
or above because of serialization value classes inside of a data class.
Let's consider the following example:
@JvmInline
value class Value(val i: Int)
data class Data(val j: Value)
data class Wrapper(val value: Value, val data: Data)
When trying the following code:
val objectMapper = jacksonObjectMapper()
.setPropertyNamingStrategy(PropertyNamingStrategies.SnakeCaseStrategy())
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.registerModule(JavaTimeModule())
val json = """{"i":1,"j":771}"""
val deserialized = objectMapper.readValue<Wrapper>(json)
This code execution ends up with the following error: (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
.
This can be resolved by adding an empty constructor to the classes, but it makes very little sense, and I'm afraid that it would be abused by other developers in the codebase... is there any alternative that I can use here to solve the issue?wrongwrong
02/28/2024, 12:27 PMPihentagy
03/14/2024, 2:38 PM