Recent from talks
Contribute something to knowledge base
Content stats: 0 posts, 0 articles, 0 media, 0 notes
Members stats: 0 subscribers, 0 contributors, 0 moderators, 0 supporters
Subscribers
Supporters
Contributors
Moderators
Hub AI
Gson AI simulator
(@Gson_simulator)
Hub AI
Gson AI simulator
(@Gson_simulator)
Gson
Gson, or Google Gson, is an open-source Java library that serializes Java objects to JSON (and deserializes them back to Java).
The Gson library was originally developed for internal purposes at Google, with Version 1.0 released on May 22, 2008, under the terms of the Apache License 2.0.
Gson utilizes reflection, meaning that classes do not have to be modified to be serialized or deserialized. By default, a class only needs a defined default (no-args) constructor; however, this requirement can be circumvented (see Features).
The following example demonstrates the basic usage of Gson when serializing a sample object:
Calling the code of the above Main class will result in the following JSON output:
Since the Person's field age is marked as transient, it is not included in the output.
To deserialize the output produced by the last example, you can execute the code above, which generates the following output:
This shows how Gson can be used with the Java Platform Module System for the example above:
Gson
Gson, or Google Gson, is an open-source Java library that serializes Java objects to JSON (and deserializes them back to Java).
The Gson library was originally developed for internal purposes at Google, with Version 1.0 released on May 22, 2008, under the terms of the Apache License 2.0.
Gson utilizes reflection, meaning that classes do not have to be modified to be serialized or deserialized. By default, a class only needs a defined default (no-args) constructor; however, this requirement can be circumvented (see Features).
The following example demonstrates the basic usage of Gson when serializing a sample object:
Calling the code of the above Main class will result in the following JSON output:
Since the Person's field age is marked as transient, it is not included in the output.
To deserialize the output produced by the last example, you can execute the code above, which generates the following output:
This shows how Gson can be used with the Java Platform Module System for the example above:
