diff --git a/index.html b/index.html index 7eebbf3..a9a3c95 100644 --- a/index.html +++ b/index.html @@ -58,7 +58,7 @@

Here is a function, which prints basic commit info (date, sha and author) from a github repository. It's also included in tests.c file, you can just uncomment and run it.

-
void print_commit_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;
diff --git a/params.json b/params.json
index b0806a3..9475562 100644
--- a/params.json
+++ b/params.json
@@ -1 +1 @@
-{"note":"Don't delete this file! It's used internally to help with page regeneration.","body":"##About\r\nParson is a lighweight [json](http://json.org) parser and reader written in C.  \r\n\r\n##Features\r\n* Lightweight (only 2 files)\r\n* Simple API\r\n* Addressing json values with dot notation (similiar to C structs or objects in most OO languages, e.g. \"objectA.objectB.value\")\r\n* C89 compatible\r\n* Test suites\r\n\r\n##Installation\r\nRun the following code:\r\n```\r\ngit clone https://github.com/kgabis/parson.git\r\n```\r\nand copy parson.h and parson.c to you source code tree.\r\n\r\nRun tests.sh to compile and run tests.\r\n\r\n##Example\r\nHere is a function, which prints basic commit info (date, sha and author) from a github repository.  It's also included in tests.c file, you can just uncomment and run it.\r\n```c\r\nvoid print_commit_info(const char *username, const char *repo) {\r\n    JSON_Value *root_value;\r\n    JSON_Array *commits;\r\n    JSON_Object *commit;\r\n    int i;\r\n    \r\n    char curl_command[512];\r\n    char cleanup_command[256];\r\n    char output_filename[] = \"commits.json\";\r\n    \r\n    /* it ain't pretty, but it's not a libcurl tutorial */\r\n    sprintf(curl_command, \"curl -s \\\"https://api.github.com/repos/%s/%s/commits\\\"\\\r\n            > %s\", username, repo, output_filename);\r\n    sprintf(cleanup_command, \"rm -f %s\", output_filename);\r\n    system(curl_command);\r\n    \r\n    /* parsing json and validating output */\r\n    root_value = json_parse_file(output_filename);\r\n    if (root_value == NULL || json_value_get_type(root_value) != JSONArray) {\r\n        system(cleanup_command);\r\n        return;\r\n    }\r\n    \r\n    /* getting array from root value and printing commit info */\r\n    commits = json_value_get_array(root_value);\r\n    printf(\"%-10.10s %-10.10s %s\\n\", \"Date\", \"SHA\", \"Author\");\r\n    for (i = 0; i < json_array_get_count(commits); i++) {\r\n        commit = json_array_get_object(commits, i);\r\n        printf(\"%.10s %.10s %s\\n\",\r\n               json_object_dotget_string(commit, \"commit.author.date\"),\r\n               json_object_get_string(commit, \"sha\"),\r\n               json_object_dotget_string(commit, \"commit.author.name\"));\r\n    }\r\n    \r\n    /* cleanup code */\r\n    json_value_free(root_value);\r\n    system(cleanup_command);\r\n}\r\n\r\n```\r\nCalling ```print_commits_info(\"torvalds\", \"linux\");``` prints:  \r\n```\r\nDate       SHA        Author\r\n2012-10-15 dd8e8c4a2c David Rientjes\r\n2012-10-15 3ce9e53e78 Michal Marek\r\n2012-10-14 29bb4cc5e0 Randy Dunlap\r\n2012-10-15 325adeb55e Ralf Baechle\r\n2012-10-14 68687c842c Russell King\r\n2012-10-14 ddffeb8c4d Linus Torvalds\r\n...\r\n```\r\n\r\n##Important\r\nParson currently supports hexadecimal and octal numbers, but they're not a part of JSON standard, so you shouldn't use them.\r\n\r\n##License\r\n[The MIT License (MIT)](http://opensource.org/licenses/mit-license.php)","tagline":"Lightweight json parser and reader written in C.","name":"parson","google":"UA-35563760-2"}
\ No newline at end of file
+{"tagline":"Lightweight json parser and reader written in C.","note":"Don't delete this file! It's used internally to help with page regeneration.","body":"##About\r\nParson is a lighweight [json](http://json.org) parser and reader written in C.  \r\n\r\n##Features\r\n* Lightweight (only 2 files)\r\n* Simple API\r\n* Addressing json values with dot notation (similiar to C structs or objects in most OO languages, e.g. \"objectA.objectB.value\")\r\n* C89 compatible\r\n* Test suites\r\n\r\n##Installation\r\nRun the following code:\r\n```\r\ngit clone https://github.com/kgabis/parson.git\r\n```\r\nand copy parson.h and parson.c to you source code tree.\r\n\r\nRun tests.sh to compile and run tests.\r\n\r\n##Example\r\nHere is a function, which prints basic commit info (date, sha and author) from a github repository.  It's also included in tests.c file, you can just uncomment and run it.\r\n```c\r\nvoid print_commits_info(const char *username, const char *repo) {\r\n    JSON_Value *root_value;\r\n    JSON_Array *commits;\r\n    JSON_Object *commit;\r\n    int i;\r\n    \r\n    char curl_command[512];\r\n    char cleanup_command[256];\r\n    char output_filename[] = \"commits.json\";\r\n    \r\n    /* it ain't pretty, but it's not a libcurl tutorial */\r\n    sprintf(curl_command, \"curl -s \\\"https://api.github.com/repos/%s/%s/commits\\\"\\\r\n            > %s\", username, repo, output_filename);\r\n    sprintf(cleanup_command, \"rm -f %s\", output_filename);\r\n    system(curl_command);\r\n    \r\n    /* parsing json and validating output */\r\n    root_value = json_parse_file(output_filename);\r\n    if (root_value == NULL || json_value_get_type(root_value) != JSONArray) {\r\n        system(cleanup_command);\r\n        return;\r\n    }\r\n    \r\n    /* getting array from root value and printing commit info */\r\n    commits = json_value_get_array(root_value);\r\n    printf(\"%-10.10s %-10.10s %s\\n\", \"Date\", \"SHA\", \"Author\");\r\n    for (i = 0; i < json_array_get_count(commits); i++) {\r\n        commit = json_array_get_object(commits, i);\r\n        printf(\"%.10s %.10s %s\\n\",\r\n               json_object_dotget_string(commit, \"commit.author.date\"),\r\n               json_object_get_string(commit, \"sha\"),\r\n               json_object_dotget_string(commit, \"commit.author.name\"));\r\n    }\r\n    \r\n    /* cleanup code */\r\n    json_value_free(root_value);\r\n    system(cleanup_command);\r\n}\r\n\r\n```\r\nCalling ```print_commits_info(\"torvalds\", \"linux\");``` prints:  \r\n```\r\nDate       SHA        Author\r\n2012-10-15 dd8e8c4a2c David Rientjes\r\n2012-10-15 3ce9e53e78 Michal Marek\r\n2012-10-14 29bb4cc5e0 Randy Dunlap\r\n2012-10-15 325adeb55e Ralf Baechle\r\n2012-10-14 68687c842c Russell King\r\n2012-10-14 ddffeb8c4d Linus Torvalds\r\n...\r\n```\r\n\r\n##Important\r\nParson currently supports hexadecimal and octal numbers, but they're not a part of JSON standard, so you shouldn't use them.\r\n\r\n##License\r\n[The MIT License (MIT)](http://opensource.org/licenses/mit-license.php)","google":"UA-35563760-2","name":"parson"}
\ No newline at end of file