Beyond JSON @ dot swift 2016

18
Beyond JSON @iceX33

Transcript of Beyond JSON @ dot swift 2016

Page 1: Beyond JSON @ dot swift 2016

Beyond JSON@iceX33

Page 2: Beyond JSON @ dot swift 2016

What was the most discussed topic of Swift community?

Page 3: Beyond JSON @ dot swift 2016

JSON parsing!

Page 4: Beyond JSON @ dot swift 2016
Page 5: Beyond JSON @ dot swift 2016

What if I tell you there is another way?

Page 6: Beyond JSON @ dot swift 2016

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

Page 7: Beyond JSON @ dot swift 2016

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

Page 8: Beyond JSON @ dot swift 2016

FlatBuffersSwift

Page 9: Beyond JSON @ dot swift 2016

What is so good about FlatBuffers?

Page 10: Beyond JSON @ dot swift 2016

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

Page 11: Beyond JSON @ dot swift 2016

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

&old code can read new data

Page 12: Beyond JSON @ dot swift 2016

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

Page 13: Beyond JSON @ dot swift 2016

{ "name": "maxim", "age" : 34}

Page 14: Beyond JSON @ dot swift 2016

12, 0, 0, 0, 8, 0, 12, 0, 4, 0, 8, 0, 8, 0, 0, 0, 8, 0, 0, 0, 34, 0, 0, 0, 5, 0, 0, 0, 109, 97, 120, 105, 109

Page 15: Beyond JSON @ dot swift 2016

FlatBuffers Swift has a really nice API:

let person = Person(name: "maxim", age: 34)person.toByteArray

Page 16: Beyond JSON @ dot swift 2016

FlatBuffers Swift has a really nice API:

let person = Person.LazyAccess(data: fbData)let age = person.age

Page 17: Beyond JSON @ dot swift 2016

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

Page 18: Beyond JSON @ dot swift 2016

Thank you@iceX33