|
Size: 1037
Comment:
|
Size: 1136
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| <<TableOfContents(2)>> |
|
| Line 4: | Line 6: |
| * https://github.com/google/gson/blob/master/UserGuide.md | * [[ https://github.com/google/gson/blob/master/UserGuide.md | User guide ]] |
| Line 7: | Line 9: |
| {{{ | {{{#!highlight xml |
| Line 9: | Line 11: |
| <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.5</version> <scope>compile</scope> </dependency> |
<groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.5</version> <scope>compile</scope> </dependency> |
| Line 18: | Line 20: |
| * http://google.github.io/gson/apidocs/com/google/gson/annotations/Expose.html * GSON gson = new GsonBuilder.excludeFieldsWithoutExposeAnnotation().create() |
* [[ http://google.github.io/gson/apidocs/com/google/gson/annotations/Expose.html | Expose ]] {{{#!highlight java GSON gson = new GsonBuilder.excludeFieldsWithoutExposeAnnotation().create() }}} |
| Line 22: | Line 25: |
| Sets the field name in the serialzied JSON. * http://google.github.io/gson/apidocs/com/google/gson/annotations/SerializedName.html |
Sets the field name in the serialized JSON. * [[ http://google.github.io/gson/apidocs/com/google/gson/annotations/SerializedName.html | SerializedName ]] |
Gson
Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object.
Maven
@Expose annotation
To use this annotation, you must create Gson by using new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(). The Gson instance created will exclude all fields in a class that are not marked with @Expose annotation.
1 GSON gson = new GsonBuilder.excludeFieldsWithoutExposeAnnotation().create()
@SerializedName annotation
Sets the field name in the serialized JSON.
