Create gh-pages branch via GitHub

This commit is contained in:
Krzysztof Gabis 2014-10-08 09:59:59 +02:00
parent ee3a3c113e
commit f0f0cd2a2f
6 changed files with 559 additions and 42 deletions

BIN
images/arrow-down.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

BIN
images/octocat-small.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

View File

@ -1,51 +1,54 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<link href='https://fonts.googleapis.com/css?family=Chivo:900' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen" />
<link rel="stylesheet" type="text/css" href="stylesheets/pygment_trac.css" media="screen" />
<link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print" />
<title>parson by kgabis</title>
<link rel="stylesheet" href="stylesheets/styles.css">
<link rel="stylesheet" href="stylesheets/pygment_trac.css">
<script src="javascripts/scale.fix.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<title>parson by kgabis</title>
</head>
<body>
<div id="container">
<div class="inner">
<div class="wrapper">
<header>
<h1>parson</h1>
<h2>Lightweight json parser and reader written in C.</h2>
<h1 class="header">parson</h1>
<p class="header">Lightweight json library written in C.</p>
<ul>
<li class="download"><a class="buttons" href="https://github.com/kgabis/parson/zipball/master">Download ZIP</a></li>
<li class="download"><a class="buttons" href="https://github.com/kgabis/parson/tarball/master">Download TAR</a></li>
<li><a class="buttons github" href="https://github.com/kgabis/parson">View On GitHub</a></li>
</ul>
<p class="header">This project is maintained by <a class="header name" href="https://github.com/kgabis">kgabis</a></p>
</header>
<section>
<h2>
<a name="about" class="anchor" href="#about"><span class="octicon octicon-link"></span></a>About</h2>
<section id="downloads" class="clearfix">
<a href="https://github.com/kgabis/parson/zipball/master" id="download-zip" class="button"><span>Download .zip</span></a>
<a href="https://github.com/kgabis/parson/tarball/master" id="download-tar-gz" class="button"><span>Download .tar.gz</span></a>
<a href="https://github.com/kgabis/parson" id="view-on-github" class="button"><span>View on GitHub</span></a>
</section>
<p>Parson is a lighweight <a href="http://json.org">json</a> library written in C.</p>
<hr>
<section id="main_content">
<h2>About</h2>
<p>Parson is a lighweight <a href="http://json.org">json</a> parser and reader written in C. </p>
<h2>Features</h2>
<h2>
<a name="features" class="anchor" href="#features"><span class="octicon octicon-link"></span></a>Features</h2>
<ul>
<li>Full JSON support</li>
<li>Lightweight (only 2 files)</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>C89 compatible</li>
<li>Test suites</li>
</ul><h2>Installation</h2>
</ul><h2>
<a name="installation" class="anchor" href="#installation"><span class="octicon octicon-link"></span></a>Installation</h2>
<p>Run the following code:</p>
<p>Run:</p>
<pre><code>git clone https://github.com/kgabis/parson.git
</code></pre>
@ -54,11 +57,15 @@
<p>Run <code>make test</code> to compile and run tests.</p>
<h2>Example</h2>
<h2>
<a name="examples" class="anchor" href="#examples"><span class="octicon octicon-link"></span></a>Examples</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>
<h3>
<a name="parsing-json" class="anchor" href="#parsing-json"><span class="octicon octicon-link"></span></a>Parsing JSON</h3>
<div class="highlight"><pre><span class="kt">void</span> <span class="nf">print_commits_info</span><span class="p">(</span><span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">username</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">repo</span><span class="p">)</span> <span class="p">{</span>
<p>Here is a function, which prints basic commit info (date, sha and author) from a github repository. </p>
<div class="highlight highlight-c"><pre><span class="kt">void</span> <span class="nf">print_commits_info</span><span class="p">(</span><span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">username</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">repo</span><span class="p">)</span> <span class="p">{</span>
<span class="n">JSON_Value</span> <span class="o">*</span><span class="n">root_value</span><span class="p">;</span>
<span class="n">JSON_Array</span> <span class="o">*</span><span class="n">commits</span><span class="p">;</span>
<span class="n">JSON_Object</span> <span class="o">*</span><span class="n">commit</span><span class="p">;</span>
@ -112,16 +119,87 @@
...
</code></pre>
<h2>License</h2>
<h3>
<a name="persistence" class="anchor" href="#persistence"><span class="octicon octicon-link"></span></a>Persistence</h3>
<p>In this example I'm using parson to save user information to a file and then load it and validate later.</p>
<div class="highlight highlight-c"><pre><span class="kt">void</span> <span class="nf">persistence_example</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="p">{</span>
<span class="n">JSON_Value</span> <span class="o">*</span><span class="n">schema</span> <span class="o">=</span> <span class="n">json_parse_string</span><span class="p">(</span><span class="s">"{</span><span class="se">\"</span><span class="s">name</span><span class="se">\"</span><span class="s">:</span><span class="se">\"\"</span><span class="s">}"</span><span class="p">);</span>
<span class="n">JSON_Value</span> <span class="o">*</span><span class="n">user_data</span> <span class="o">=</span> <span class="n">json_parse_file</span><span class="p">(</span><span class="s">"user_data.json"</span><span class="p">);</span>
<span class="kt">char</span> <span class="n">buf</span><span class="p">[</span><span class="mi">256</span><span class="p">];</span>
<span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">name</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">user_data</span> <span class="o">||</span> <span class="o">!</span><span class="n">json_validate</span><span class="p">(</span><span class="n">schema</span><span class="p">,</span> <span class="n">user_data</span><span class="p">)</span> <span class="o">==</span> <span class="n">JSONSuccess</span><span class="p">)</span> <span class="p">{</span>
<span class="n">puts</span><span class="p">(</span><span class="s">"Enter your name:"</span><span class="p">);</span>
<span class="n">scanf</span><span class="p">(</span><span class="s">"%s"</span><span class="p">,</span> <span class="n">buf</span><span class="p">);</span>
<span class="n">user_data</span> <span class="o">=</span> <span class="n">json_value_init_object</span><span class="p">();</span>
<span class="n">json_object_set_string</span><span class="p">(</span><span class="n">json_object</span><span class="p">(</span><span class="n">user_data</span><span class="p">),</span> <span class="s">"name"</span><span class="p">,</span> <span class="n">buf</span><span class="p">);</span>
<span class="n">json_serialize_to_file</span><span class="p">(</span><span class="n">user_data</span><span class="p">,</span> <span class="s">"user_data.json"</span><span class="p">);</span>
<span class="p">}</span>
<span class="n">name</span> <span class="o">=</span> <span class="n">json_object_get_string</span><span class="p">(</span><span class="n">json_object</span><span class="p">(</span><span class="n">user_data</span><span class="p">),</span> <span class="s">"name"</span><span class="p">);</span>
<span class="n">printf</span><span class="p">(</span><span class="s">"Hello, %s."</span><span class="p">,</span> <span class="n">name</span><span class="p">);</span>
<span class="n">json_value_free</span><span class="p">(</span><span class="n">schema</span><span class="p">);</span>
<span class="n">json_value_free</span><span class="p">(</span><span class="n">user_data</span><span class="p">);</span>
<span class="k">return</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<h3>
<a name="serialization" class="anchor" href="#serialization"><span class="octicon octicon-link"></span></a>Serialization</h3>
<p>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.</p>
<div class="highlight highlight-c"><pre><span class="kt">void</span> <span class="nf">serialization_example</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="p">{</span>
<span class="n">JSON_Value</span> <span class="o">*</span><span class="n">root_value</span> <span class="o">=</span> <span class="n">json_value_init_object</span><span class="p">();</span>
<span class="n">JSON_Object</span> <span class="o">*</span><span class="n">root_object</span> <span class="o">=</span> <span class="n">json_value_get_object</span><span class="p">(</span><span class="n">root_value</span><span class="p">);</span>
<span class="kt">char</span> <span class="o">*</span><span class="n">serialized_string</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
<span class="n">json_object_set_string</span><span class="p">(</span><span class="n">root_object</span><span class="p">,</span> <span class="s">"name"</span><span class="p">,</span> <span class="s">"John Smith"</span><span class="p">);</span>
<span class="n">json_object_set_number</span><span class="p">(</span><span class="n">root_object</span><span class="p">,</span> <span class="s">"age"</span><span class="p">,</span> <span class="mi">25</span><span class="p">);</span>
<span class="n">json_object_dotset_string</span><span class="p">(</span><span class="n">root_object</span><span class="p">,</span> <span class="s">"address.city"</span><span class="p">,</span> <span class="s">"Cupertino"</span><span class="p">);</span>
<span class="n">json_object_dotset_value</span><span class="p">(</span><span class="n">root_object</span><span class="p">,</span> <span class="s">"contact.emails"</span><span class="p">,</span> <span class="n">json_parse_string</span><span class="p">(</span><span class="s">"[</span><span class="se">\"</span><span class="s">email@example.com</span><span class="se">\"</span><span class="s">,</span><span class="se">\"</span><span class="s">email2@example.com</span><span class="se">\"</span><span class="s">]"</span><span class="p">));</span>
<span class="n">serialized_string</span> <span class="o">=</span> <span class="n">json_serialize_to_string</span><span class="p">(</span><span class="n">root_value</span><span class="p">);</span>
<span class="n">puts</span><span class="p">(</span><span class="n">serialized_string</span><span class="p">);</span>
<span class="n">json_free_serialized_string</span><span class="p">(</span><span class="n">serialized_string</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
<p>Created value (after formatting outside parson):</p>
<pre><code>{
"name":"John Smith",
"age":25,
"address":{
"city":"Cupertino"
},
"contact":{
"emails":[
"email@example.com",
"email2@example.com"
]
}
}
</code></pre>
<h2>
<a name="contributing" class="anchor" href="#contributing"><span class="octicon octicon-link"></span></a>Contributing</h2>
<p>I will always merge <em>working</em> bug fixes. However, if you want to add something to the API,
I <em>won't</em> merge it without prior discussion.
Remember to follow parson's code style and write appropriate tests.</p>
<h2>
<a name="license" class="anchor" href="#license"><span class="octicon octicon-link"></span></a>License</h2>
<p><a href="http://opensource.org/licenses/mit-license.php">The MIT License (MIT)</a></p>
</section>
<footer>
parson is maintained by <a href="https://github.com/kgabis">kgabis</a><br>
This page was generated by <a href="http://pages.github.com">GitHub Pages</a>. Tactile theme by <a href="http://twitter.com/jasonlong">Jason Long</a>.
<p><small>Hosted on <a href="http://pages.github.com">GitHub Pages</a> using the Dinky theme</small></p>
</footer>
</div>
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
@ -133,7 +211,5 @@
} catch(err) {}
</script>
</div>
</div>
</body>
</html>

20
javascripts/scale.fix.js Normal file
View File

@ -0,0 +1,20 @@
fixScale = function(doc) {
var addEvent = 'addEventListener',
type = 'gesturestart',
qsa = 'querySelectorAll',
scales = [1, 1],
meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];
function fix() {
meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
doc.removeEventListener(type, fix, true);
}
if ((meta = meta[meta.length - 1]) && addEvent in doc) {
fix();
scales = [.25, 1.6];
doc[addEvent](type, fix, true);
}
};

File diff suppressed because one or more lines are too long

421
stylesheets/styles.css Normal file
View File

@ -0,0 +1,421 @@
@import url(https://fonts.googleapis.com/css?family=Arvo:400,700,400italic);
/* MeyerWeb Reset */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font: inherit;
vertical-align: baseline;
}
/* Base text styles */
body {
padding:10px 50px 0 0;
font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
color: #232323;
background-color: #FBFAF7;
margin: 0;
line-height: 1.8em;
-webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 {
color:#232323;
margin:36px 0 10px;
}
p, ul, ol, table, dl {
margin:0 0 22px;
}
h1, h2, h3 {
font-family: Arvo, Monaco, serif;
line-height:1.3;
font-weight: normal;
}
h1,h2, h3 {
display: block;
border-bottom: 1px solid #ccc;
padding-bottom: 5px;
}
h1 {
font-size: 30px;
}
h2 {
font-size: 24px;
}
h3 {
font-size: 18px;
}
h4, h5, h6 {
font-family: Arvo, Monaco, serif;
font-weight: 700;
}
a {
color:#C30000;
font-weight:200;
text-decoration:none;
}
a:hover {
text-decoration: underline;
}
a small {
font-size: 12px;
}
em {
font-style: italic;
}
strong {
font-weight:700;
}
ul {
list-style: inside;
padding-left: 25px;
}
ol {
list-style: decimal inside;
padding-left: 20px;
}
blockquote {
margin: 0;
padding: 0 0 0 20px;
font-style: italic;
}
dl, dt, dd, dl p {
font-color: #444;
}
dl dt {
font-weight: bold;
}
dl dd {
padding-left: 20px;
font-style: italic;
}
dl p {
padding-left: 20px;
font-style: italic;
}
hr {
border:0;
background:#ccc;
height:1px;
margin:0 0 24px;
}
/* Images */
img {
position: relative;
margin: 0 auto;
max-width: 650px;
padding: 5px;
margin: 10px 0 32px 0;
border: 1px solid #ccc;
}
p img {
display: inline;
margin: 0;
padding: 0;
vertical-align: middle;
text-align: center;
border: none;
}
/* Code blocks */
code, pre {
font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace;
color:#000;
font-size:14px;
}
pre {
padding: 4px 12px;
background: #FDFEFB;
border-radius:4px;
border:1px solid #D7D8C8;
overflow: auto;
overflow-y: hidden;
margin-bottom: 32px;
}
/* Tables */
table {
width:100%;
}
table {
border: 1px solid #ccc;
margin-bottom: 32px;
text-align: left;
}
th {
font-family: 'Arvo', Helvetica, Arial, sans-serif;
font-size: 18px;
font-weight: normal;
padding: 10px;
background: #232323;
color: #FDFEFB;
}
td {
padding: 10px;
background: #ccc;
}
/* Wrapper */
.wrapper {
width:960px;
}
/* Header */
header {
background-color: #171717;
color: #FDFDFB;
width:170px;
float:left;
position:fixed;
border: 1px solid #000;
-webkit-border-top-right-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
-moz-border-radius-topright: 4px;
-moz-border-radius-bottomright: 4px;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
padding: 34px 25px 22px 50px;
margin: 30px 25px 0 0;
-webkit-font-smoothing: antialiased;
}
p.header {
font-size: 16px;
}
h1.header {
font-family: Arvo, sans-serif;
font-size: 30px;
font-weight: 300;
line-height: 1.3em;
border-bottom: none;
margin-top: 0;
}
h1.header, a.header, a.name, header a{
color: #fff;
}
a.header {
text-decoration: underline;
}
a.name {
white-space: nowrap;
}
header ul {
list-style:none;
padding:0;
}
header li {
list-style-type: none;
width:132px;
height:15px;
margin-bottom: 12px;
line-height: 1em;
padding: 6px 6px 6px 7px;
background: #AF0011;
background: -moz-linear-gradient(top, #AF0011 0%, #820011 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd));
background: -webkit-linear-gradient(top, #AF0011 0%,#820011 100%);
background: -o-linear-gradient(top, #AF0011 0%,#820011 100%);
background: -ms-linear-gradient(top, #AF0011 0%,#820011 100%);
background: linear-gradient(top, #AF0011 0%,#820011 100%);
border-radius:4px;
border:1px solid #0D0D0D;
-webkit-box-shadow: inset 0px 1px 1px 0 rgba(233,2,38, 1);
box-shadow: inset 0px 1px 1px 0 rgba(233,2,38, 1);
}
header li:hover {
background: #C3001D;
background: -moz-linear-gradient(top, #C3001D 0%, #950119 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd));
background: -webkit-linear-gradient(top, #C3001D 0%,#950119 100%);
background: -o-linear-gradient(top, #C3001D 0%,#950119 100%);
background: -ms-linear-gradient(top, #C3001D 0%,#950119 100%);
background: linear-gradient(top, #C3001D 0%,#950119 100%);
}
a.buttons {
-webkit-font-smoothing: antialiased;
background: url(../images/arrow-down.png) no-repeat;
font-weight: normal;
text-shadow: rgba(0, 0, 0, 0.4) 0 -1px 0;
padding: 2px 2px 2px 22px;
height: 30px;
}
a.github {
background: url(../images/octocat-small.png) no-repeat 1px;
}
a.buttons:hover {
color: #fff;
text-decoration: none;
}
/* Section - for main page content */
section {
width:650px;
float:right;
padding-bottom:50px;
}
/* Footer */
footer {
width:170px;
float:left;
position:fixed;
bottom:10px;
padding-left: 50px;
}
@media print, screen and (max-width: 960px) {
div.wrapper {
width:auto;
margin:0;
}
header, section, footer {
float:none;
position:static;
width:auto;
}
footer {
border-top: 1px solid #ccc;
margin:0 84px 0 50px;
padding:0;
}
header {
padding-right:320px;
}
section {
padding:20px 84px 20px 50px;
margin:0 0 20px;
}
header a small {
display:inline;
}
header ul {
position:absolute;
right:130px;
top:84px;
}
}
@media print, screen and (max-width: 720px) {
body {
word-wrap:break-word;
}
header {
padding:10px 20px 0;
margin-right: 0;
}
section {
padding:10px 0 10px 20px;
margin:0 0 30px;
}
footer {
margin: 0 0 0 30px;
}
header ul, header p.view {
position:static;
}
}
@media print, screen and (max-width: 480px) {
header ul li.download {
display:none;
}
footer {
margin: 0 0 0 20px;
}
footer a{
display:block;
}
}
@media print {
body {
padding:0.4in;
font-size:12pt;
color:#444;
}
}