google / google/gson

JsonSerializer/Deserializer: Allow reflection-oriented implementations

Open
#594 1 comment 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

```
It would be nice to use the JsonSerializer interface (or something similar) on
the class itself, rather than in a separate utility class which then needs to
be registered as a type adapter. In this manner, the interface would need to
look like:

JsonElement serialize(JsonSerializationContext context)

, allowing the class to use the current object's state for serialization. Gson
could reflect prior to serializing and, if it implements this interface,
delegate to it rather than do the normal class/field reflection.

A similar notion could be done for the deserialization side. This would be
similar to how Java serializable/externalizable mechanisms work.
```

Original issue reported on code.google.com by `ShahakNa...@gmail.com` on 2 Sep 2014 at 4:14

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.