File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1
1
package com.fasterxml.jackson.module.kotlin.test.github
2
2
3
+ import com.fasterxml.jackson.annotation.JsonCreator
3
4
import com.fasterxml.jackson.databind.annotation.JsonSerialize
4
5
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer
5
6
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
@@ -18,6 +19,14 @@ class TestGithub269 {
18
19
constructor (strPattern: String ) : this (Regex (strPattern))
19
20
}
20
21
22
+ data class Zoo (
23
+ @JsonSerialize(using = ToStringSerializer ::class )
24
+ val myPattern : Regex
25
+ ) {
26
+ @JsonCreator
27
+ constructor (strPattern: String ) : this (Regex (strPattern))
28
+ }
29
+
21
30
@Test
22
31
fun testGithub269WithFoo () {
23
32
val mapper = jacksonObjectMapper()
@@ -56,4 +65,15 @@ class TestGithub269 {
56
65
57
66
assertEquals(testObject.myPattern.pattern, resultObject.myPattern.pattern)
58
67
}
68
+
69
+ @Test
70
+ fun testGithub269WithZoo () {
71
+ val mapper = jacksonObjectMapper()
72
+
73
+ val testObject = Zoo (Regex (" test_pattern_1" ))
74
+ val testJson = mapper.writeValueAsString(testObject)
75
+ val resultObject = mapper.readValue<Zoo >(testJson)
76
+
77
+ assertEquals(testObject.myPattern.pattern, resultObject.myPattern.pattern)
78
+ }
59
79
}
You can’t perform that action at this time.
0 commit comments