Skip to content

syb0rg/parcel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

parcel

Build status Build Status

An efficient and functional JSON parsing library written in C. parcel was designed to be small and portable for seamless integration will resource-constrained systems.


Features

  • Backwards compatable with the C99 standard.

  • No external dependencies.

  • Proved to be faster then other JSON parsing libraries in benchmarking tests.

  • Follows strict JSON syntax

  • Includes Doxygen comments for generating documentation

Design

parcel splits a JSON file into tokens. Consider the following example of JSON data:

{
     "firstName": "John",
     "lastName": "Smith",
     "address": {
         "streetAddress": "21 2nd Street",
         "city": "New York",
         "state": "NY",
         "postalCode": 10021
     },
     "phoneNumbers": [
         "212 555-1234",
         "646 555-4567"
     ]
}

parcel will split that data into the following tokens based on the JSON values:

  • Objects: { "firstName": "John", "lastName": "Smith", "address": { "streetAddress": "21 2nd Street", "city": "New York", "state": "NY", "postalCode": 10021 }, "phoneNumbers": [ "212 555-1234", "646 555-4567" ] } (the whole object), { "streetAddress": "21 2nd Street", "city": "New York", "state": "NY", "postalCode": 10021 }

  • Arrays: [ "212 555-1234", "646 555-4567" ]

  • Strings: "firstName", "John", "lastName", "Smith", "address", "streetAddress", "21 2nd Street", "city", "New York", "state", "NY", "postalCode", "phoneNumbers", "212 555-1234", "646 555-4567"

  • Primitives (a number, boolean, or NULL): 10021

However, it is important to note that parcel only points to the token boundaries. Taking the example from above:

  • Objects: [0, 286], [76, 203]

  • Arrays: [227, 283]

And so on for Strings and Primitives. Besides that token boundaries, parcel tokens for more complex data types (objects and arrays), also contain the number of child items, so you can easily follow the hierarchy.

This approach provides enough information for parsing any JSON data and makes it possible to use zero-copy techniques; making the parsing of JSON data a lot faster and more simple.


TODO

  • Finish documentation.

  • Add a more flexable JSON item retrieval function.

  • Support Unicode characters.

  • Add example usage to README.

About

An efficient and functional JSON parser written in C.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published