File tree 5 files changed +32
-2
lines changed
jr-objects/src/main/java/com/fasterxml/jackson/jr/ob
jr-stree/src/main/java/com/fasterxml/jackson/jr/stree
5 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -1685,6 +1685,11 @@ private static class ExtContextImpl extends ExtensionContext {
1685
1685
_builder = b ;
1686
1686
}
1687
1687
1688
+ @ Override
1689
+ public boolean isEnabled (JSON .Feature feature ) {
1690
+ return _builder .isEnabled (feature );
1691
+ }
1692
+
1688
1693
@ Override
1689
1694
public ExtensionContext setTreeCodec (TreeCodec tc ) {
1690
1695
_builder .treeCodec (tc );
Original file line number Diff line number Diff line change 1
1
package com .fasterxml .jackson .jr .ob .api ;
2
2
3
3
import com .fasterxml .jackson .core .TreeCodec ;
4
+ import com .fasterxml .jackson .jr .ob .JSON ;
4
5
5
6
/**
6
7
* API that lets {@link com.fasterxml.jackson.jr.ob.JacksonJrExtension}s to register handlers
10
11
*/
11
12
public abstract class ExtensionContext
12
13
{
14
+ // // // Config access
15
+
16
+ /**
17
+ * Method for checking whether given {@code JSON.Feature} is enabled.
18
+ *
19
+ * @param feature Feature to check
20
+ *
21
+ * @return True if given {@code JSON.Feature} is enabled; {@code false} if not
22
+ *
23
+ * @since 2.17
24
+ */
25
+ public abstract boolean isEnabled (JSON .Feature feature );
26
+
13
27
// // // Override of (and access to) singleton handlers
14
28
15
29
/**
Original file line number Diff line number Diff line change @@ -16,8 +16,11 @@ public class JacksonJrsTreeCodec extends TreeCodec
16
16
17
17
public static final JacksonJrsTreeCodec SINGLETON = new JacksonJrsTreeCodec ();
18
18
19
- protected ObjectCodec _objectCodec ;
19
+ protected final ObjectCodec _objectCodec ;
20
20
21
+ // @since 2.17
22
+ protected boolean _failOnDuplicateKeys ;
23
+
21
24
public JacksonJrsTreeCodec () {
22
25
this (null );
23
26
}
@@ -26,6 +29,11 @@ public JacksonJrsTreeCodec(ObjectCodec codec) {
26
29
_objectCodec = codec ;
27
30
}
28
31
32
+ // @since 2.17
33
+ public void setFailOnDuplicateKeys (boolean state ) {
34
+ _failOnDuplicateKeys = state ;
35
+ }
36
+
29
37
@ SuppressWarnings ("unchecked" )
30
38
@ Override
31
39
public <T extends TreeNode > T readTree (JsonParser p ) throws IOException {
Original file line number Diff line number Diff line change 1
1
package com .fasterxml .jackson .jr .stree ;
2
2
3
+ import com .fasterxml .jackson .jr .ob .JSON ;
3
4
import com .fasterxml .jackson .jr .ob .JacksonJrExtension ;
4
5
import com .fasterxml .jackson .jr .ob .api .ExtensionContext ;
5
6
@@ -23,9 +24,10 @@ public JrSimpleTreeExtension() {
23
24
public JrSimpleTreeExtension (JacksonJrsTreeCodec tc ) {
24
25
_codec = tc ;
25
26
}
26
-
27
+
27
28
@ Override
28
29
protected void register (ExtensionContext ctxt ) {
30
+ _codec .setFailOnDuplicateKeys (ctxt .isEnabled (JSON .Feature .FAIL_ON_DUPLICATE_MAP_KEYS ));
29
31
ctxt .setTreeCodec (_codec );
30
32
}
31
33
}
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ Not yet released
15
15
16
16
#7 : Support deserialization of `int []`
17
17
(contributed by @Shounaks )
18
+ #131 : Add mechanism for `JacksonJrExtension `s to access state of `JSON .Feature `s
18
19
19
20
2.17 .0 - rc1 (26 - Feb - 2024 )
20
21
You can’t perform that action at this time.
0 commit comments