Create gh-pages branch via GitHub

gh-pages
Krzysztof Gabis 12 years ago
parent 2ef517e9aa
commit b455cde8ac
  1. 23
      index.html
  2. 2
      params.json

@ -4,7 +4,7 @@
<head> <head>
<meta charset='utf-8' /> <meta charset='utf-8' />
<meta http-equiv="X-UA-Compatible" content="chrome=1" /> <meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta name="description" content="parson : Small json parser and reader written in C." /> <meta name="description" content="parson : Lightweight json parser and reader written in C." />
<link rel="stylesheet" type="text/css" media="screen" href="stylesheets/stylesheet.css"> <link rel="stylesheet" type="text/css" media="screen" href="stylesheets/stylesheet.css">
@ -19,7 +19,7 @@
<a id="forkme_banner" href="https://github.com/kgabis/parson">View on GitHub</a> <a id="forkme_banner" href="https://github.com/kgabis/parson">View on GitHub</a>
<h1 id="project_title">parson</h1> <h1 id="project_title">parson</h1>
<h2 id="project_tagline">Small json parser and reader written in C.</h2> <h2 id="project_tagline">Lightweight json parser and reader written in C.</h2>
<section id="downloads"> <section id="downloads">
<a class="zip_download_link" href="https://github.com/kgabis/parson/zipball/master">Download this project as a .zip file</a> <a class="zip_download_link" href="https://github.com/kgabis/parson/zipball/master">Download this project as a .zip file</a>
@ -33,12 +33,12 @@
<section id="main_content" class="inner"> <section id="main_content" class="inner">
<h2>About</h2> <h2>About</h2>
<p>Parson is a small <a href="http://json.org">json</a> parser and reader written in C. </p> <p>Parson is a lighweight <a href="http://json.org">json</a> parser and reader written in C. </p>
<h2>Features</h2> <h2>Features</h2>
<ul> <ul>
<li>Small (only 2 files)</li> <li>Lightweight (only 2 files)</li>
<li>Simple API</li> <li>Simple API</li>
<li>Addressing json values with dot notation (similiar to C structs or objects in most OO languages, e.g. "objectA.objectB.value")</li> <li>Addressing json values with dot notation (similiar to C structs or objects in most OO languages, e.g. "objectA.objectB.value")</li>
<li>C89 compatible</li> <li>C89 compatible</li>
@ -52,6 +52,8 @@
<p>and copy parson.h and parson.c to you source code tree.</p> <p>and copy parson.h and parson.c to you source code tree.</p>
<p>Run tests.sh to compile and run tests.</p>
<h2>Example</h2> <h2>Example</h2>
<p>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.</p> <p>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.</p>
@ -64,17 +66,17 @@
<span class="kt">char</span> <span class="n">curl_command</span><span class="p">[</span><span class="mi">512</span><span class="p">];</span> <span class="kt">char</span> <span class="n">curl_command</span><span class="p">[</span><span class="mi">512</span><span class="p">];</span>
<span class="kt">char</span> <span class="n">cleanup_command</span><span class="p">[</span><span class="mi">256</span><span class="p">];</span> <span class="kt">char</span> <span class="n">cleanup_command</span><span class="p">[</span><span class="mi">256</span><span class="p">];</span>
<span class="kt">char</span> <span class="o">*</span><span class="n">output_filename</span> <span class="o">=</span> <span class="s">"commits.json"</span><span class="p">;</span> <span class="kt">char</span> <span class="n">output_filename</span><span class="p">[]</span> <span class="o">=</span> <span class="s">"commits.json"</span><span class="p">;</span>
<span class="cm">/* it ain't pretty, but it's not a libcurl tutorial */</span> <span class="cm">/* it ain't pretty, but it's not a libcurl tutorial */</span>
<span class="n">sprintf</span><span class="p">(</span><span class="n">curl_command</span><span class="p">,</span> <span class="s">"curl </span><span class="se">\"</span><span class="s">https://api.github.com/repos/%s/%s/commits</span><span class="se">\"</span><span class="s">\</span> <span class="n">sprintf</span><span class="p">(</span><span class="n">curl_command</span><span class="p">,</span> <span class="s">"curl -s </span><span class="se">\"</span><span class="s">https://api.github.com/repos/%s/%s/commits</span><span class="se">\"</span><span class="s">\</span>
<span class="s"> &gt; %s 2&gt; /dev/null"</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">repo</span><span class="p">,</span> <span class="n">output_filename</span><span class="p">);</span> <span class="s"> &gt; %s"</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">repo</span><span class="p">,</span> <span class="n">output_filename</span><span class="p">);</span>
<span class="n">sprintf</span><span class="p">(</span><span class="n">cleanup_command</span><span class="p">,</span> <span class="s">"rm -f %s"</span><span class="p">,</span> <span class="n">output_filename</span><span class="p">);</span> <span class="n">sprintf</span><span class="p">(</span><span class="n">cleanup_command</span><span class="p">,</span> <span class="s">"rm -f %s"</span><span class="p">,</span> <span class="n">output_filename</span><span class="p">);</span>
<span class="n">system</span><span class="p">(</span><span class="n">curl_command</span><span class="p">);</span> <span class="n">system</span><span class="p">(</span><span class="n">curl_command</span><span class="p">);</span>
<span class="cm">/* parsing json and validating output */</span> <span class="cm">/* parsing json and validating output */</span>
<span class="n">root_value</span> <span class="o">=</span> <span class="n">json_parse_file</span><span class="p">(</span><span class="n">output_filename</span><span class="p">);</span> <span class="n">root_value</span> <span class="o">=</span> <span class="n">json_parse_file</span><span class="p">(</span><span class="n">output_filename</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">root_value</span> <span class="o">==</span> <span class="nb">NULL</span> <span class="o">||</span> <span class="n">json_value_get_type</span><span class="p">(</span><span class="n">root_value</span><span class="p">)</span> <span class="o">!=</span> <span class="n">JSONArray</span><span class="p">)</span> <span class="p">{</span> <span class="k">if</span> <span class="p">(</span><span class="n">root_value</span> <span class="o">==</span> <span class="nb">NULL</span> <span class="o">||</span> <span class="n">json_value_get_type</span><span class="p">(</span><span class="n">root_value</span><span class="p">)</span> <span class="o">!=</span> <span class="n">JSONArray</span><span class="p">)</span> <span class="p">{</span>
<span class="n">system</span><span class="p">(</span><span class="n">cleanup_command</span><span class="p">);</span> <span class="n">system</span><span class="p">(</span><span class="n">cleanup_command</span><span class="p">);</span>
<span class="k">return</span><span class="p">;</span> <span class="k">return</span><span class="p">;</span>
<span class="p">}</span> <span class="p">}</span>
@ -94,9 +96,10 @@
<span class="n">json_value_free</span><span class="p">(</span><span class="n">root_value</span><span class="p">);</span> <span class="n">json_value_free</span><span class="p">(</span><span class="n">root_value</span><span class="p">);</span>
<span class="n">system</span><span class="p">(</span><span class="n">cleanup_command</span><span class="p">);</span> <span class="n">system</span><span class="p">(</span><span class="n">cleanup_command</span><span class="p">);</span>
<span class="p">}</span> <span class="p">}</span>
</pre></div> </pre></div>
<p>Calling <code>print_commit_info("torvalds", "linux");</code> prints: </p> <p>Calling <code>print_commits_info("torvalds", "linux");</code> prints: </p>
<pre><code>Date SHA Author <pre><code>Date SHA Author
2012-10-15 dd8e8c4a2c David Rientjes 2012-10-15 dd8e8c4a2c David Rientjes

@ -1 +1 @@
{"note":"Don't delete this file! It's used internally to help with page regeneration.","body":"##About\r\nParson is a small [json](http://json.org) parser and reader written in C. \r\n\r\n##Features\r\n* Small (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\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 \\\"https://api.github.com/repos/%s/%s/commits\\\"\\\r\n > %s 2> /dev/null\", 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\nCalling ```print_commit_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)","name":"parson","google":"UA-35563760-2","tagline":"Small 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_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"}
Loading…
Cancel
Save