Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

edoc cleanup

  • Loading branch information...
commit d2a41ac29df212cccbca5f3e5804459292504ec6 1 parent a72ad81
@etrepum etrepum authored
Showing with 36 additions and 3 deletions.
  1. +1 −0  .gitignore
  2. +32 −0 src/mochijson2.erl
  3. +3 −3 src/mochiweb_http.erl
View
1  .gitignore
@@ -1,3 +1,4 @@
/ebin
/doc
/_test
+/docs
View
32 src/mochijson2.erl
@@ -4,6 +4,38 @@
%% @doc Yet another JSON (RFC 4627) library for Erlang. mochijson2 works
%% with binaries as strings, arrays as lists (without an {array, _})
%% wrapper and it only knows how to decode UTF-8 (and ASCII).
+%%
+%% JSON terms are decoded as follows (javascript -> erlang):
+%% <ul>
+%% <li>{"key": "value"} ->
+%% {struct, [{&lt;&lt;"key">>, &lt;&lt;"value">>}]}</li>
+%% <li>["array", 123, 12.34, true, false, null] ->
+%% [&lt;&lt;"array">>, 123, 12.34, true, false, null]
+%% </li>
+%% </ul>
+%% <ul>
+%% <li>Strings in JSON decode to UTF-8 binaries in Erlang</li>
+%% <li>Objects decode to {struct, PropList}</li>
+%% <li>Numbers decode to integer or float</li>
+%% <li>true, false, null decode to their respective terms.</li>
+%% </ul>
+%% The encoder will accept the same format that the decoder will produce,
+%% but will also allow additional cases for leniency:
+%% <ul>
+%% <li>atoms other than true, false, null will be considered UTF-8
+%% strings (even as a proplist key)
+%% </li>
+%% <li>{json, IoList} will insert IoList directly into the output
+%% with no validation
+%% </li>
+%% <li>{array, Array} will be encoded as Array
+%% (legacy mochijson style)
+%% </li>
+%% <li>A non-empty raw proplist will be encoded as an object as long
+%% as the first pair does not have an atom key of json, struct,
+%% or array
+%% </li>
+%% </ul>
-module(mochijson2).
-author('bob@mochimedia.com').
View
6 src/mochiweb_http.erl
@@ -37,9 +37,9 @@ start() ->
%% @spec start(Options) -> ServerRet
%% Options = [option()]
-%% Option = {name, atom()} | {ip, string() | tuple()} | {backlog, integer()}
-%% | {nodelay, boolean()} | {acceptor_pool_size, integer()}
-%% | {ssl, boolean()} | {profile_fun, undefined | fun/1}
+%% Option = {name, atom()} | {ip, string() | tuple()} | {backlog, integer()}
+%% | {nodelay, boolean()} | {acceptor_pool_size, integer()}
+%% | {ssl, boolean()} | {profile_fun, undefined | (Props) -> ok}
%% @doc Start a mochiweb server.
%% profile_fun is used to profile accept timing.
%% After each accept, if defined, profile_fun is called with a proplist of a subset of the mochiweb_socket_server state and timing information.
Please sign in to comment.
Something went wrong with that request. Please try again.