以 C 语言编写的轻量级 JSON 库。
Parson is a lightweight json library written in C.
Run:
git clone https://github.com/kgabis/parson.git
and copy parson.h and parson.c to you source code tree.
Run make test to compile and run tests.
Here is a function, which prints basic commit info (date, sha and author) from a github repository.
…
Calling print_commits_info("torvalds", "linux"); prints:
Date SHA Author
2012-10-15 dd8e8c4a2c David Rientjes
2012-10-15 3ce9e53e78 Michal Marek
2012-10-14 29bb4cc5e0 Randy Dunlap
2012-10-15 325adeb55e Ralf Baechle
2012-10-14 68687c842c Russell King
2012-10-14 ddffeb8c4d Linus Torvalds
...
In this example I'm using parson to save user information to a file and then load it and validate later.
…
Creating JSON values is very simple thanks to the dot notation. Object hierarchy is automatically created when addressing specific fields. In the following example I create a simple JSON value containing basic information about a person.
…
Output:
{
"name": "John Smith",
"age": 25,
"address": {
"city": "Cupertino"
},
"contact": {
"emails": [
"[email protected]",
"[email protected]"
]
}
}
I will always merge working bug fixes. However, if you want to add something new to the API, please create an "issue" on github for this first so we can discuss if it should end up in the library before you start implementing it. Remember to follow parson's code style and write appropriate tests.
暂无开放 Issues,或尚未同步最近议题。