Adopt Protocol Buffers instead of JSON
Protocol Buffers are a data interchange format used in Google. (also developed by Google)
It looks like as follows.
package main;
message Book {
required string title = 1;
required int32 page_number = 2;
required string author_name = 3;
}
Protocol buffers encoded data are binary. They are encoded really efficiently.
You can compare them with JSON. Protocol buffers encoded messages using .proto
above can be represented in JSON as follows.
{
"title": "SomeTitle",
"page_count": 12,
"author_name": "SomeAuthor"
}
What is different between Protocol Buffers and JSON is serializing and deserializing. Because protocol buffers specifies its structure in .proto
(You saw above), Protocol Buffers serialized data can be deserialized easily as follows. (Assume that bookData
is protobuf serialized data.)
Book *book = [Book parseFromData:bookData]
The structure is described...