Browse Source

ドキュメントを追加

Takeru Ohta 11 years ago
parent
commit
573c053f55
6 changed files with 221 additions and 4 deletions
  1. 1 1
      Makefile
  2. 59 1
      README.md
  3. 11 0
      doc/README.md
  4. 146 0
      doc/jsone.md
  5. 3 1
      rebar.config
  6. 1 1
      src/jsone.app.src

+ 1 - 1
Makefile

@@ -5,7 +5,7 @@ DIALYZER_OPTS=-Werror_handling -Wrace_conditions -Wunmatched_returns
 
 
 DEPENDED_APPS=
 DEPENDED_APPS=
 
 
-all: compile xref eunit dialyze
+all: compile xref eunit edoc dialyze
 
 
 init:
 init:
 	@./rebar get-deps compile 
 	@./rebar get-deps compile 

+ 59 - 1
README.md

@@ -1 +1,59 @@
-http://www.ietf.org/rfc/rfc4627.txt
+jsone (0.1.0)
+=============
+
+Erlangで実装されたJSONのエンコード/デコードライブラリ。
+
+特徴
+----
+- RFC4627準拠
+- 日本語を含む文字列に対応
+  - ただし文字列はUTF-8のみをサポート
+- Pure Erlang
+- デコード処理部を実験的にCPS的に実装
+  - パース途中にサブバイナリが生成されることを極力抑制して最適化
+
+ビルド方法
+----------
+ビルドツールには[rebar](https://github.com/basho/rebar)を使用している。
+
+ビルド手順:
+```sh
+# ビルド
+$ git clone git://github.com/sile/jsone.git
+$ make init
+
+# テスト & dialyzer 実行
+$ make
+
+# ロードパスに追加してErlangシェルを起動
+$ make start
+1> jsone:decode(<<"[1,2,3]">>).
+[1,2,3]
+```
+
+API
+---
+[EDOCドキュメント](doc/jsone.md)
+
+使用例
+-----
+```erlang
+%% デコード
+> jsone:decode(<<"[1,2,3]">>).
+{[1,2,3],<<>>}                  % 返り値は {デコード結果, 未使用バイナリ} 形式
+
+> json:decode(<<"{\"1\":2}">>).
+{{object,[{<<"1">>,2}]},<<>>}   % オブジェクトは {object, [Key, Value]} 形式にデコードされる
+
+%% エンコード
+> jsone:encode([1,2,3]).
+[91,[[<<"1">>,44,<<"2">>],44,<<"3">>],93]  % iodata()が返る
+
+> iolist_to_binary(jsone:encode([1,2,3])).
+<<"[1,2,3]">>
+```
+
+参考
+----
+- [JSON](http://www.json.org/)
+- [RFC4627](http://www.ietf.org/rfc/rfc4627.txt)

+ 11 - 0
doc/README.md

@@ -0,0 +1,11 @@
+
+
+# The jsone application #
+
+
+## Modules ##
+
+
+<table width="100%" border="0" summary="list of modules">
+<tr><td><a href="jsone.md" class="module">jsone</a></td></tr></table>
+

+ 146 - 0
doc/jsone.md

@@ -0,0 +1,146 @@
+
+
+# Module jsone #
+* [Description](#description)
+* [Data Types](#types)
+* [Function Index](#index)
+* [Function Details](#functions)
+
+
+JSON decoding/encoding module.
+
+
+<a name="types"></a>
+
+## Data Types ##
+
+
+
+
+### <a name="type-json_array">json_array()</a> ###
+
+
+
+<pre><code>
+json_array() = [<a href="#type-json_value">json_value()</a>]
+</code></pre>
+
+
+
+
+
+### <a name="type-json_boolean">json_boolean()</a> ###
+
+
+
+<pre><code>
+json_boolean() = boolean()
+</code></pre>
+
+
+
+
+
+### <a name="type-json_number">json_number()</a> ###
+
+
+
+<pre><code>
+json_number() = number()
+</code></pre>
+
+
+
+
+
+### <a name="type-json_object">json_object()</a> ###
+
+
+
+<pre><code>
+json_object() = {object, <a href="#type-json_object_members">json_object_members()</a>}
+</code></pre>
+
+
+
+
+
+### <a name="type-json_object_members">json_object_members()</a> ###
+
+
+
+<pre><code>
+json_object_members() = [{<a href="#type-json_string">json_string()</a>, <a href="#type-json_value">json_value()</a>}]
+</code></pre>
+
+
+
+
+
+### <a name="type-json_string">json_string()</a> ###
+
+
+
+<pre><code>
+json_string() = binary()
+</code></pre>
+
+
+
+
+
+### <a name="type-json_value">json_value()</a> ###
+
+
+
+<pre><code>
+json_value() = <a href="#type-json_number">json_number()</a> | <a href="#type-json_string">json_string()</a> | <a href="#type-json_array">json_array()</a> | <a href="#type-json_object">json_object()</a> | <a href="#type-json_boolean">json_boolean()</a> | null
+</code></pre>
+
+
+<a name="index"></a>
+
+## Function Index ##
+
+
+<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#decode-1">decode/1</a></td><td>JSONバイナリをデコードする.</td></tr><tr><td valign="top"><a href="#encode-1">encode/1</a></td><td>JSON値をiodata形式にエンコードする.</td></tr></table>
+
+
+<a name="functions"></a>
+
+## Function Details ##
+
+<a name="decode-1"></a>
+
+### decode/1 ###
+
+
+<pre><code>
+decode(Json::binary()) -&gt; {<a href="#type-json_value">json_value()</a>, RestJson::binary()}
+</code></pre>
+
+<br></br>
+
+
+
+JSONバイナリをデコードする.
+
+
+デコードに失敗した場合はエラーが送出される
+<a name="encode-1"></a>
+
+### encode/1 ###
+
+
+<pre><code>
+encode(JsonValue::<a href="#type-json_value">json_value()</a>) -&gt; iodata()
+</code></pre>
+
+<br></br>
+
+
+
+JSON値をiodata形式にエンコードする.
+
+
+エンコードに失敗した場合はエラーが送出される

+ 3 - 1
rebar.config

@@ -16,6 +16,7 @@
 {cover_enabled, true}.
 {cover_enabled, true}.
  
  
 {edoc_opts, [
 {edoc_opts, [
+             {doclet, edown_doclet},
              {dialyzer_specs, all},
              {dialyzer_specs, all},
              {report_missing_type, true}, 
              {report_missing_type, true}, 
              {report_type_mismatch, true},
              {report_type_mismatch, true},
@@ -26,5 +27,6 @@
  
  
 {deps,
 {deps,
   [
   [
-   {meck, ".*", {git, "git://github.com/eproxus/meck.git", {tag, "0.8"}}}
+   {meck, ".*", {git, "git://github.com/eproxus/meck.git", {tag, "0.8"}}},
+   {edown, ".*", {git, "git://github.com/sile/edown.git", {branch, "master"}}}
   ]}.
   ]}.

+ 1 - 1
src/jsone.app.src

@@ -2,7 +2,7 @@
 {application, jsone,
 {application, jsone,
  [
  [
   {description, "Erlang JSON Library"},
   {description, "Erlang JSON Library"},
-  {vsn, "0.0.1"},
+  {vsn, "0.1.0"},
   {registered, []},
   {registered, []},
   {applications, [
   {applications, [
                   kernel,
                   kernel,