Skip to content

Commit 7b57a59

Browse files
authored
Update migration-from-gson.md
1 parent ccc07e5 commit 7b57a59

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

migration-from-gson.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,26 @@ title: How to extend
44
---
55

66
# Migration from gson
7+
8+
Jsoniter support gson annotation, migrating from gson to jsoniter should be easy.
9+
10+
```
11+
public static class TestObject {
12+
@Expose(deserialize = false)
13+
public String field1;
14+
}
15+
16+
Gson gson = new GsonBuilder()
17+
.excludeFieldsWithoutExposeAnnotation()
18+
.create();
19+
TestObject obj = gson.fromJson("{\"field1\":\"hello\"}", TestObject.class);
20+
```
21+
22+
will be
23+
24+
```
25+
GsonCompatibilityMode config = new GsonCompatibilityMode.Builder()
26+
.excludeFieldsWithoutExposeAnnotation()
27+
.build();
28+
TestObject obj = JsonIterator.deserialize(config, "{\"field1\":\"hello\"}", TestObject.class);
29+
```

0 commit comments

Comments
 (0)