ZippyJSON Documentation

repository·master·Indexed 21 days ago

https://github.com/michaeleisel/zippyjson

A high-performance replacement for Swift's JSONDecoder optimized for versions prior to iOS 17. ZippyJSON utilizes C++ and the simdjson library to provide faster JSON parsing via ZippyJSONDecoder, which maintains the same API as the standard Foundation implementation.

Tokens
457
Snippets
3
Records
4
Agent score
26%

What's inside ZippyJSON

  1. When to use ZippyJSON vs JSONDecoder

    master

    ZippyJSON is designed to optimize JSON parsing performance, which can often be a bottleneck in data delivery.

    Decision Guide:

    1. Default: Start with the standard JSONDecoder as it is battle-tested.
    2. Profile: If you identify JSON parsing as a performance bottleneck, measure the time taken.
    3. Estimate: A rule of thumb is to divide the current parsing time by 4 to approximate the time with ZippyJSON.
    4. Switch: If that difference is significant to your application's user experience, switch to ZippyJSONDecoder.

    Note: If you are targeting iOS 17+, stick with the native JSONDecoder as it is faster than ZippyJSON on that platform.

  2. Use ZippyJSONDecoder as a drop-in replacement for JSONDecoder

    master

    ZippyJSON provides ZippyJSONDecoder, which has the exact same API as Apple's JSONDecoder. To use it, import the module and replace the standard decoder initialization.

    Important: When measuring performance, ensure you are building for release mode.

    Note on Compatibility: For iOS 17+, Apple's JSONDecoder is faster than ZippyJSON. This library is intended for use on versions prior to iOS 17 to improve parsing performance.

    import ZippyJSON
    
    // Instead of:
    // let decoder = JSONDecoder()
    
    // Use:
    let decoder = ZippyJSONDecoder()