A JSON parser / serializer written in C.
0 Try it
1 Download
2 Build
3 Example
3.1 Example input
3.2 Example output
4 Tester
5.1 Type definitions
Wait for a few moments, then click the play button on the bottom of the window. This will run the example program.
To download json, execute the following command
$ git clone https://github.com/Jacob-C-Smith/json --recurse-submodules
To build on UNIX like machines, execute the following commands in the same directory
$ cd json
$ cmake .
$ make
This will build the example program, and dynamic / shared libraries
To build json for Windows machines, open the base directory in Visual Studio, and build your desired target(s)
NOTE: If you are running the tester program on Windows, you may have to copy example files to the Debug
or Release
directories.
The example program parses the input file, and writes the parsed tokens to stdout. To run the example program, execute this command.
./json_example file1.json [file2.json ... fileN.json]
{
"name" : "Jacob Smith",
"age" : 20,
"height" : 1.775,
"dog" : {
"name" : "Eddie",
"sex" : "Male",
"breed" : "Terrier"
},
"interests" : [
"Computer science",
"3D modeling",
"Organic chemistry",
"Mathematics",
"Computer games",
"Epistemology"
]
}
--- example.json ---
{"name":"Jacob Smith","age":20,"height":1.775,"dog":{"name":"Eddie","sex":"Male","breed":"Terrier"},"interests":["Computer science","3D modeling","Organic chemistry","Mathematics","Computer games","Epistemology"]}
NOTE: If you are running the tester program on Windows, you may have to copy the serial test cases
and parse test cases
directories to the Debug
or Release
directories.
To run the tester program, execute this command after building
$ ./json_test
typedef struct json_value_s json_value;
// Parser
int json_value_parse ( char *text, char **return_pointer, json_value **const pp_value );
// Serializer
int json_value_serialize ( const json_value *const p_value, char *_buffer );
int json_value_print ( const json_value *const p_value );
int json_value_fprint ( const json_value *const p_value, FILE *p_f );
// Destructor
void json_value_free ( json_value *p_value );