Slide 1

Slide 1 text

Deeper look at RFC7159: the revised specification of JSON Urabe, Shyouhei. DeNA Co., Ltd.

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

New RFC to specify JSON was released last month!

Slide 4

Slide 4 text

So I created a new gem

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Why another JSON library?

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

So a conforming JSON library … ● MUST always generate JSON text that STRICTLY conforms the RFC, without ANY extensions such as NaNs. Otherwise that generator is not a conforming JSON library. ● MUST always understand ALL expression that the RFC permits, NO MATTER HOW strange that specific expression is, or even impossible to represent in Ruby. Otherwise that parser is not a conforming JSON library. This is hard!

Slide 10

Slide 10 text

How to tackle this situation

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Line-by-line translation into racc and…

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

… and 100+ acceptance tests.

Slide 15

Slide 15 text

Some interesting cases include:

Slide 16

Slide 16 text

This is by design, but out of date.

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Should I stop using Yajl / Oj ? ● I don't think so. ● They are useful. Just having little bugs. All programms do so more or less. I don't want to point them at finger. ● On the other hand, the library I created is strict-but-useless. It exhibits paranoia behaviour, too strict to reject converting most Ruby objects into JSON, while too tolerant to accept almost any texts, and most importantly, RUNS TOO SLOW.

Slide 22

Slide 22 text

Fast enough to take 1.6+ secs for parsing 32KB

Slide 23

Slide 23 text

Maybe JSON needs better trade-offs ● Proper treatments of evil escapes, like [”\uD800”], is the nightmare that causes this slow-down. ● Ignoring them only should greatly speed things up. ● JSON spec might better be updated to explicitly forbid invalid sequences, even if they are escaped. ● Everyone should stop generate such thing today.

Slide 24

Slide 24 text

URLs to refer: ● http://tools.ietf.org/html/rfc7159 ● https://github.com/shyouhei/RFC7159 ● https://rubygems.org/gems/RFC7159 Thank you!