Coder Social home page Coder Social logo

formulamonks / jsonlite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amamchur/jsonlite

3.0 9.0 1.0 3.53 MB

High performance and low memory footprint C/Objective-C JSON parser for mobile/embedded systems

Objective-C 61.84% C 37.74% C++ 0.30% Ruby 0.11% Shell 0.01%

jsonlite's Introduction

Introduction to jsonlite

What is jsonlite and JsonLite ObjC

jsonlite is JSON tokenizer. It's lightweight C library that can be used for low-level JSON processing or parser development.

JsonLite for Objective-C is JSON parser base on jsonlite. It's the high performance and flexible JSON parser for Objective-C. You may use JsonLiteObj instead of NSJSONSerialization when your application needs:

  • Avoid duplicates of key & value
  • Binding/mapping JSON to model
  • Serialization model to JSON
  • Working with NSURL, NSDate, NSDecimal or base64
  • Chunk processing
  • Custom converters

Design Principles

jsonlite designed as goto driven finite state machine. This approach provides a lot of benefits such as:

  • Very very fast parsing
  • Low memory footprint
  • Streaming parsing
  • Depth checking
  • Size of JSON payload doesn't influence memory usage
  • Recursion free
  • Good testability
Lightweight

jsonlite is super lite parser. It's perfect works on microcontrollers with 2k RAM.

Memory usage for parsing depth 32:

  • 64-bit platform - 200 bytes
  • 32-bit platform - 116 bytes
Divide and Rule (divide et impera)

It's main principle of jsonlite design. jsonlite doesn't perform any decoding by itself, but provides reach API for token processing instead of that. Let's look at the following example:

{
  "string":"Some\u0020string"
}

In this case we have string with escaped UNICODE character and jsonlite will provide all information about this token.

token.start == 12; // Start of "Some\u0020string"
token.end == 28; // End of "Some\u0020string"
token.type.string == jsonlite_string_ascii | jsonlite_string_unicode_escape; // Token attributes

And now is your turn, you may:

  • Decode token (jsonlite_token_to_uft8 or jsonlite_token_to_uft16)
  • Pass it as raw value to jsonlite_builder (see Beautifier example)
  • Terminate parsing using jsonlite_parser_terminate
  • Or something else

jsonlite - divides; you - rule.

Code Coverage

  • 100% Function coverage
  • 100% Statement coverage
  • 100% Branch coverage.

See Code coverage configuration

Image

License

jsonlite and JsonLite ObjC are licensed under the Apache License, Version 2.0

Copyright 2012-2013, Andrii Mamchur

jsonlite's People

Contributors

amamchur avatar andrii-mamchur avatar xxuejie avatar azu avatar

Stargazers

 avatar Kristin Peterson avatar  avatar

Watchers

Cyril David avatar Will Jessup avatar Bruno Deferrari avatar Brady Brim-DeForest avatar  avatar James Cloos avatar Corey avatar Citrusbyte Frontend avatar  avatar

Forkers

ssizebra

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.