Gson: Enjoy JSON (De-)Serialization in Java (eBook & Workbook)
$30.00
Minimum price
$35.00
Suggested price

Gson: Enjoy JSON (De-)Serialization in Java

About the Book

Learn Every Detail About Gson

Every modern Java application will need to do some Java-JSON parsing in their application life cycle. Gson is the most commonly used library to do the Java-JSON serialization and deserialization automatically.

Data parsing and mapping is complex. Even though Gson makes things quite simple, there are a lot of details that can trip your development up. If it's crazy data structures, weird variable names or complex dynamic data, you can lose a lot of time on something that should be done in minutes. Gson solves most problems in just a few lines. You just need to know the solutions!

This book includes an extensive introduction to Gson's features. We recommend to read it before you even have to use Gson for the first time. But even if you're already an avid user of Gson and stuck at a problem, we're confident we'll solve your problem.

Use our extensive bundle to learn about:

  • Introduction to JSON & JSON-Java mapping
  • Quick start to jump right into Gson
  • Mapping of any Java type
  • Deep dive into Gson's configuration options
  • Practical examples of Gson customization
  • Even advanced topics (Streaming, Generics, ...) are covered
  • Necessary ProGuard configuration for Android app releases

Additionally, you'll get an extensive appendix:

  • Combining a customized Gson with Retrofit 2
  • Overview over common mistakes
  • Exploration of Gson alternatives

Who Is This Book For?

This book is for Android or Java developers who want to get a substantial overview and reference book for Gson. You’ll benefit from the clearly recognizable code examples in regard to your daily work with Gson.

Rookie

If you’re just starting out with Gson (or coming from any other Java-JSON library like Jackson databind) this book will show you all important parts on how to work with Gson. The provided code snippets let you jumpstart and create the first mapping within minutes.

Expert

You already worked with Gson before? You’ll profit from our extensive code snippets and can improve your existing code base. Additionally, the book illustrates various optimizations for an even better performance.

Code Samples

Every code snippet in the book has been tested. We provide our test project as a leanpub extra. Feel free to download it and check the full code base as you move through the book. We try to keep the code snippets in the book as short as possible. If more context is necessary, the code examples should provide it.

Workbook

For the first time, we provide additional separated resources besides our book. The workbook gives you a chance to implement everything you'll learn in this book yourself. In our experience actually using a library like Gson helps to reinforce the newly gained knowledge. Thus, we've designed the workbook, which gives you a guided playground to experiment and learn the features of Gson.

  • Share this book

  • Categories

    • Computers and Programming
    • Java
    • Android
    • JavaScript
  • Feedback

    Email the Author(s)

About the Author

Future Studio
Norman Peitek

Norman is passionate Android developer since 2011. He's developed multiple apps, which have been used by millions of users overall. Building high-quality products is always Norman's #1 focus. While working as an Android freelancer and consultant is his day job, he loves teaching and passing on knowledge on the side.

Since 2014, Norman started working on the API side as well. Developing node.js apps is a good alternative and provides some good insight into becoming a better programmer overall.

Norman has a Master's degree from the Otto von Guericke University Magdeburg.

Feel free to get in touch on twitter @peitek or LinkedIn.

Packages

Just The eBook

Includes:

  • extras
    Gson Sample Code

    Code snippets of the book in action as an Android project.

  • PDF

  • EPUB

  • WEB

  • English

$25.00
Minimum price
$30.00
Suggested price
eBook & Workbook

Includes:

  • extras
    Gson Sample Code

    Code snippets of the book in action as an Android project.

  • PDF

  • EPUB

  • WEB

  • English

$30.00
Minimum price
$35.00
Suggested price

Bundles that include this book

$123.00
Bought separately
$85.00
Bundle Price
$78.00
Bought separately
$50.00
Bundle Price

About the Contributors

Christian Fellner
Christian Fellner

Christian is an experienced Software Engineer and consultant working with a wide variety of companies, ranging from startups to Fortune 500 companies.

His experiences range across a number of fields and technologies, including web and game development, virtual reality and machine learning.

Christian is an all-round nerd, passionate about outstanding design and creating innovational user experiences.

He has given training to many developers and students since 2011; explaining state of the art technologies and project management methodologies.

Christian has a BSc degree in Computer Systems in Engineering from the Otto von Guericke University Magdeburg.

Find him on Twitter: @celsiusF.

Marcus Pöhls
Marcus Pöhls

Marcus is an enthusiastic Android & Java developer. He’s developed multiple production-ready client and server applications. While following the core principle of performance for client apps, he also builds REST+JSON APIs that focus on clear and consistent design.

Besides his day job, sharing knowledge and teaching others has become a characteristic he never wants to miss.

Marcus has a Master’s degree in computer science from the Otto von Guericke University Magdeburg.

Feel free to get in touch on Twitter @marcuspoehls.

Table of Contents

  • About the Book
    • What Topics Are Covered in This Book?
    • Who Is This Book For?
    • Code Examples
    • Workbook
  • Chapter 1 — Introduction to Java-JSON Mapping
    • Adding Gson as Dependency
    • Basics of Java-JSON Serialization
    • Basics of Java-JSON Deserialization
  • Chapter 2 — JSON Mapping with Gson
    • Mapping of Nested Objects
    • Mapping of Arrays and Lists of Objects
    • Mapping of Maps
    • Mapping of Sets
    • Mapping of Null Values
  • Chapter 3 — Gson Model Annotations
    • How to Ignore Fields
    • How to Adjust the Naming of Fields
    • Multiple Deserialization Names with @SerializedName
  • Chapter 4 — Configuring Gson with GsonBuilder
    • GsonBuilder Basics
    • Naming Policies
    • Force Serialization of null Values
    • Go Beyond transient and @Expose with Exclusion Strategies
    • Relax Gson with Lenient
    • Special Values of Floats/Doubles
    • Model Versioning
    • Formatting of Dates & Custom Date/Time Mapping
    • Pretty Printing
    • HTML Escaping
  • Chapter 5 — Advanced Gson Usage
    • Mapping of Enums
    • Mapping of Circular References
    • Mapping of Generics
    • Custom Serialization for Simplification (Part 1)
    • Changing the Default Serialization with Custom Serialization (Part 2)
    • Custom Deserialization Basics
    • Custom Instance Creator
    • Customizing (De)Serialization via @JsonAdapter
    • Custom Deserialization for Calculated Fields
    • On-The-Fly-Parsing With Streams
  • Chapter 6 — ProGuard Configuration
    • Gson and ProGuard Are Not Best Friends
    • Standard Gson Configuration
  • Chapter 7 — Practical Gson
    • Low Level Parsing
    • Storing Data in Android’s SharedPreferences With Gson
    • How to Deserialize a List of Polymorphic Objects
  • Chapter 8 — Appendix
    • Gson’s Configuration for Retrofit 2
    • 5 Common Mistakes & Issues
    • Overview of Alternatives
  • Outro
    • Workbook
  • Future Studio Books
    • Retrofit
    • Picasso
    • Glide
    • Future Studio Bundle

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub