summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2011-01-09 10:42:52 +0100
committerYorhel <git@yorhel.nl>2011-01-09 10:42:52 +0100
commit5a683d3499260cd772e8115d10ad7424685044ee (patch)
tree04e2d8be4354110ba3ca0c7076400ed7745c5556
parentab6e3ead83707a7029f9bccc276d31d6f423a8e2 (diff)
Added MIT license to each file + some extra notes to json.mllHEADmaster
-rw-r--r--COPYING2
-rw-r--r--json.mll70
-rw-r--r--main.ml21
-rw-r--r--vndbApi.ml21
4 files changed, 95 insertions, 19 deletions
diff --git a/COPYING b/COPYING
index 4c931dd..265256a 100644
--- a/COPYING
+++ b/COPYING
@@ -1,4 +1,4 @@
-Copyright (c) 2010 Yoran Heling
+Copyright (c) 2010-2011 Yoran Heling
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
diff --git a/json.mll b/json.mll
index 184c1c0..84581a1 100644
--- a/json.mll
+++ b/json.mll
@@ -1,9 +1,58 @@
-(* Very minimal standard-compliant JSON parser/generator, because the currently
- * available JSON libraries for OCaml try to do too much and have too many
- * dependencies.
+(* Copyright (c) 2010-2011 Yoran Heling
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *)
+
+(* This is a very minimal standard-compliant JSON parser/generator, because the
+ * currently available JSON libraries for OCaml try to do too much and have too
+ * many dependencies.
+ *
* - The aim of this library is to be small rather than fast.
+ * It was made to parse and generate small (~1kB to 100kB) messages.
+ * Performance should be acceptable as long as the input does not contain long
+ * strings with a lot of escaped characters. (e.g. binary data encoded in a
+ * JSON string is a bad idea.)
+ *
* - Error detecting is correct. Error reporting, however, is rather minimal.
+ *
+ * - This library conforms to RFC 4627, with two exceptions:
+ * 1. The top-level JSON value does not have to be an array or object, but can
+ * be any valid JSON value. An application would have to check for the type
+ * of the value anyway.
+ * 2. All data after the end of the JSON string is ignored, and may thus
+ * contain garbage. For example, the following JSON string is valid:
+ * true{"data":1}
+ * Parsing that will simply give you (Bool true)
+ *
+ * - All data is assumed to be encoded in UTF-8
+ * In particular:
+ * - When parsing, \uxxxx string escapes are converted into their UTF-8
+ * representation.
+ * - When serializing, all non-printable 7-bit string characters are escaped
+ * to their native JSON control character (e.g. \b or \t) or as \u00xx.
+ * Everything else is passed as-is.
+ *
+ * Note that I have not fully tested how this library reacts to various forms of
+ * JSON input, but I do not expect any major problems.
* (Some portions and ideas of this code were borrowed from yojson)
+ *
*)
@@ -249,18 +298,3 @@ let get_value obj key =
}
-
-
-
-
-(* Testing stuff...
-
-#load "_build/json.cmo";;
-open Json;;
-get_bool;;
-
-let obj = json_of_string "{\"num\":1,\"more\":false,\"items\":[{\"language\":\"ja\",\"original\":null,\"name\":\"Studi\\u007Fo e.go!\",\"type\":\"co\",\"id\":17}]}";;
-string_of_json obj;;
-
-*)
-
diff --git a/main.ml b/main.ml
index fd884ab..67f2aa6 100644
--- a/main.ml
+++ b/main.ml
@@ -1,3 +1,24 @@
+(* Copyright (c) 2010-2011 Yoran Heling
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *)
(* global useful functions *)
let config_dir create =
diff --git a/vndbApi.ml b/vndbApi.ml
index 9565f25..7200ef6 100644
--- a/vndbApi.ml
+++ b/vndbApi.ml
@@ -1,3 +1,24 @@
+(* Copyright (c) 2010-2011 Yoran Heling
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *)
open Unix