Book Image

Libgdx Cross-platform Game Development Cookbook

Book Image

Libgdx Cross-platform Game Development Cookbook

Overview of this book

Table of Contents (20 chapters)
Libgdx Cross-platform Game Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

JSON serialization and deserialization


JSON stands for JavaScript Object Notation and it is an open standard, human readable format to transmit objects formed by attribute-value pairs. It has become very popular to transmit data between clients and servers, but it is also heavily used in games as an alternative of XML.

Originally, it came from JavaScript, although it is actually language agnostic as there are many utilities to write and read JSON in virtually every widely used language. Being less verbose than XML and easier to parse are probably its main advantages when compared to the aforementioned format.

JSON is really awesome, but in order to be able to follow this recipe, make sure you are familiar with the basics. Check out http://www.json.org for more details.

In this recipe, you will learn how to deserialize (read) Java objects from JSON files and serialize them back to JSON.

Getting ready

Make sure you have the sample projects in your Eclipse workspace.

How to do it…

The code for this...