-

-About

+ + +
+
+ View on GitHub + +

parson

+

Lightweight json library written in C.

+ +
+ Download this project as a .zip file + Download this project as a tar.gz file +
+
+
+ + +
+
+

+About

Parson is a lighweight json library written in C.

-Features

+Features
  • Full JSON support
  • @@ -37,7 +49,7 @@

-Installation

+Installation

Run:

@@ -49,14 +61,14 @@

Run make test to compile and run tests.

-Examples

+Examples

-Parsing JSON

+Parsing JSON

Here is a function, which prints basic commit info (date, sha and author) from a github repository.

-
void print_commits_info(const char *username, const char *repo) {
+
void print_commits_info(const char *username, const char *repo) {
     JSON_Value *root_value;
     JSON_Array *commits;
     JSON_Object *commit;
@@ -110,11 +122,11 @@
 

-Persistence

+Persistence

In this example I'm using parson to save user information to a file and then load it and validate later.

-
void persistence_example(void) {
+
void persistence_example(void) {
     JSON_Value *schema = json_parse_string("{\"name\":\"\"}");
     JSON_Value *user_data = json_parse_file("user_data.json");
     char buf[256];
@@ -134,13 +146,13 @@
 }

-Serialization

+Serialization

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.

-
void serialization_example(void) {
+
void serialization_example(void) {
     JSON_Value *root_value = json_value_init_object();
     JSON_Object *root_object = json_value_get_object(root_value);
     char *serialized_string = NULL;
@@ -173,26 +185,27 @@ In the following example I create a simple JSON value containing basic informati
 

-Contributing

+Contributing -

I will always merge working bug fixes. However, if you want to add something to the API, -I won't merge it without prior discussion. +

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.

-License

+License

The MIT License (MIT)

- -
+
+ + + -