Skip to content

Commit 18caa33

Browse files
authored
Update java-features.md
1 parent 463e1c0 commit 18caa33

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

java-features.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ then set the mode to dynamic code generation
116116
```java
117117
JsonIterator.setMode(DecodingMode.DYNAMIC_MODE_AND_MATCH_FIELD_WITH_HASH);
118118
JsonStream.setMode(EncodingMode.DYNAMIC_MODE);
119-
JsoniterAnnotationSupport.enable();
120119
```
121120

122121
everything should still works, just much much faster
@@ -143,7 +142,6 @@ Or, we can set the default decoding mode to reflection
143142

144143
```java
145144
JsonIterator.setMode(DecodingMode.REFLECTION_MODE);
146-
JsoniterAnnotationSupport.enable();
147145
```
148146

149147
All features is supported using the reflection mode, just slower, but still faster than existing solutions. Here is a quick benchmark of simple object field binding:
@@ -230,7 +228,6 @@ The final step is to switch mode
230228

231229
```java
232230
JsonIterator.setMode(DecodingMode.STATIC_MODE); // set mode before using
233-
JsoniterAnnotationSupport.enable();
234231
JsonIterator.deserialize(...
235232
```
236233

@@ -320,13 +317,7 @@ public class TestObject {
320317

321318
**binding**
322319

323-
mark the class with jsoniter annotation, then enable annotation support. Or if you are already using jackson, you can still use jackson annotation, just turn on JacksonAnnotationSupport. It is important to mark `@JsonProperty` with field name, as old java version can not get parameter name by reflection.
324-
325-
```java
326-
JacksonAnnotationSupport.enable(); // use JsoniterAnnotationSupport if you are not using Jackson
327-
return iter.read(TestObject.class);
328-
```
329-
320+
It is important to mark `@JsonProperty` with field name, as old java version can not get parameter name by reflection.
330321
Not only constructor binding is supported, static method working as factory method is also supported. Just mark it with `@JsonCreator`.
331322

332323
## Setter Binding
@@ -372,7 +363,6 @@ public static class TestObject {
372363
```
373364

374365
```java
375-
JsoniterAnnotationSupport.enable();
376366
return iter.read(TestObject.class);
377367
```
378368

@@ -515,7 +505,6 @@ public static class TestObject {
515505
if `field1` is not present in the input json, exception will be thrown.
516506

517507
```java
518-
JsoniterAnnotationSupport.enable();
519508
JsonIterator iter = JsonIterator.parse("{'field2':101}".replace('\'', '"'));
520509
return iter.read(TestObject.class);
521510
```
@@ -560,7 +549,6 @@ public static class TestObject2 {
560549
using `asExtraForUnknownProperties` we can detect if the input has extra fields. Enable the annotation support:
561550

562551
```java
563-
JsoniterAnnotationSupport.enable();
564552
JsonItertor iter = JsonIterator.parse("{'field1':101,'field2':101,'field3':101}".replace('\'', '"').getBytes());
565553
return iter.read(TestObject2.class);
566554
```

0 commit comments

Comments
 (0)