Beyond JSON with FlatBuffers

13
Beyond JSON @iceX33 Game developer at Wooga

Transcript of Beyond JSON with FlatBuffers

Page 1: Beyond JSON with FlatBuffers

Beyond JSON@iceX33Game developer at Wooga

Page 2: Beyond JSON with FlatBuffers

What was the most discussed topic of Swift community?

Page 3: Beyond JSON with FlatBuffers

JSON parsing!

Page 4: Beyond JSON with FlatBuffers

What if I tell you there is another way?

Page 5: Beyond JSON with FlatBuffers

Meet FlatBuffersIt was originally created at Google for game development and other performance-critical applications.

Page 6: Beyond JSON with FlatBuffers

FlatBuffersis an efficient cross platform serialization library for C++, Java, C#, Go, Python and JavaScript (C, PHP & Ruby in progress).

Page 7: Beyond JSON with FlatBuffers

FlatBuffersSwift

Page 8: Beyond JSON with FlatBuffers

What is so good about FlatBuffers?

Page 9: Beyond JSON with FlatBuffers

There is no parsing involved!!!Reading data can be done lazy (almost zero cost)

Page 10: Beyond JSON with FlatBuffers

It's backwards and forwards compatiblenew code can read old data

&old code can read new data

Page 11: Beyond JSON with FlatBuffers

It's not human readableAnd it's a good thing! (Easy to encrypt and to compress)

Page 12: Beyond JSON with FlatBuffers

FlatBuffers Swift has a really nice API:

let data = NSData(contentsOfFile: "contactList.bin")!let byteArray = UnsafePointer<UInt8>(data.bytes)

let contactList = ContactList.fromByteArray(byteArray)

if let birthday = contactList.entries[5]?.birthday { birthday.day = 12 birthday.month = 6}

let newData = config.toByteArray

Page 13: Beyond JSON with FlatBuffers

If you are interested or want to get involved?https://github.com/mzaks/FlatBuffersSwift