talira

Chunk-based JSON parser and generator for Objective-C

open sourceBSD-3-Clausefree

SBJson is a strict JSON parser and generator in Objective-C whose main feature is stream- or chunk-based parsing. You feed the parser chunks of UTF-8 data and it calls a block for each root-level document, or for each entry of a root-level array, so an app can start using a document before it has finished downloading and can parse very large documents without holding them in memory. The writer can sort dictionary keys and pretty-print, input has a configurable maximum nesting depth, and versions 3, 4 and 5 can be installed side by side.

Problems it solves

  • parse a large JSON download incrementally on iOS
  • start processing JSON before the whole response has arrived in Objective-C
  • parse a huge JSON array without loading it all into memory on macOS

Features

  • chunk-based parsing of multiple root documents or a huge root array
  • maps JSON to Foundation types, with booleans and 64-bit integers kept exact
  • configurable maximum nesting depth
  • writer with sorted keys and human-readable output
  • versions 3, 4 and 5 installable side by side

Limitations

  • Its README marks it Inactive: stable, but no longer actively developed, with maintenance as time allows.1
  • Stream parsing can return early parts of a document as if correct before an error turns up later in the input.1