Skip to Content
Native Mobile Development
book

Native Mobile Development

by Shaun Lewis, Mike Dunn
November 2019
Intermediate to advanced
394 pages
9h 44m
English
O'Reilly Media, Inc.
Content preview from Native Mobile Development

Chapter 12. Serialization and Transports

To serialize an object we convert the abstract concept (the “model”) to transportable entities, usually either a String representation of the model, like XML or JSON, or bytes.

To deserialize data means to convert it from a series of entities to an object your program recognizes. For example, you might have an Author entity with a name property.

Tasks

In this chapter, you’ll learn to:

  1. Serialize and deserialize an object instance.

Android

Android uses a lot of XML internally, but in the real world, JSON is still the primary serialization mechanism (although larger organizations with plenty of engineering resources have started to embrace “protobuf,” or Protocol Buffers). This is a neat concept and highly performant, but beyond the scope of our examination of the framework and standard APIs.

Serialize and Deserialize an Object Instance

In Java and Android, deserialization probably starts with a data model, like this:

Deserialized to JSON, an Author instance that returned “Mike” by invoking getName would probably look like this:

{ name : "Mike" }

Once it’s in JSON format, it can be passed along with a network request, written to disk, or even handed off to another program in wildly different technologies; since the JSON format has an established ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pro iPhone Development with SwiftUI: Design and Manage Top Quality Apps

Pro iPhone Development with SwiftUI: Design and Manage Top Quality Apps

Wallace Wang
Ionic in Action

Ionic in Action

Jeremy Wilken
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz

Publisher Resources

ISBN: 9781492052869Errata PageSupplemental Content