google / google/gson

Add possibility to avoid parsing of subdocuments

Open
#756 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
24.2k
Forks
4.5k
Avg merge
6d 4h
Merged PRs (30d)
12

Description

For example, if you have the following JSON document:

``` javascript
{
"prop1":"val1",
"prop2":"val2",
"subdocument": { /* complex nested object here */ }
}
```

I want to parse it into Java object such as this:

``` java
public class Message {
@Expose public String prop1;
@Expose public String prop2;
@Subdocument public String subdocument;
}
```

After parsing, `prop1` and `prop2` will be stored normally into the fields, and the `subdocument` will contain raw JSON string. The `@Subdocument` annotation is suggested.

When serializing such object, the subdocument should be appended to the serialized output as is, i.e. without syntax checking, or the check should be optional, again due to performance.

I need this because I receive some data in the background thread on a mobile device, and the data is not needed at that time. It will be stored as raw JSON to database and parsed later, when needed. This will save memory and increase performance.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.