Coder Social home page Coder Social logo

zippyjson's Introduction

ZippyJSON

A much faster version of JSONDecoder

Carthage compatible Cocoapods compatible

Benchmarks

These benchmarks were done on an iPhone 8. The results are very similar on MacOS.

Usage

Because it is drop-in, simply add the library to your project and replace JSONDecoder with ZippyJSONDecoder anywhere you want to use it. The library is feature-complete, so it will support any use cases you have.

Why is it so much faster?

  • Apple's version first converts the JSON into an NSDictionary using NSJSONSerialization and then afterwards makes things Swifty. The creation of that intermediate dictionary is expensive.
  • ZippyJSON is built largely in C++ (but still with a Swift interface wrapped around it). For the initial parsing (you might call it tokenizing), it uses simdjson, a very fast library that makes good use of vectorization. Apple, on the other hand, uses entirely Swift (aside from the use of NSJSONSerialization) which is generally slower.
  • There are many specific optimizations in there as well. For example, date parsing for ISO-8601 dates is 10x faster due to using JJLISO8601DateFormatter instead of Apple's date formatter.

So, it's largely due to Apple trying to be elegant and operate at a higher level.

Stability

ZippyJSON uses all the same unit tests that Apple uses for their JSONDecoder, and then some, so it should generally work. However, it is a new release. Feel free to submit a ticket if you find any issues.

Future improvements

There are still many places in the code that are ripe for optimization. Feel free to submit a ticket if you have a specific case where you need more performant JSON parsing, and where ZippyJSON is not already 4x faster than Apple's. JSONEncoder and NSJSONSerialization are also promising for optimzation, please chime in if you need one of these improved.

Installation

Cocoapods

ZippyJSON is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ZippyJSON'

Carthage

To install it, add the following to your Cartfile:

github "michaeleisel/ZippyJSON"

Author

Michael Eisel, [email protected]

zippyjson's People

Contributors

michaeleisel avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.