diff options
author | Mark Pulford <mark@kyne.com.au> | 2011-05-01 16:44:01 +0930 |
---|---|---|
committer | Mark Pulford <mark@kyne.com.au> | 2011-05-01 16:44:01 +0930 |
commit | 439e03c6f9296ade78985a8d0b5c892846b6b06a (patch) | |
tree | 466e92e4b2f48ee7ac9b82a6141375e4c1e8408b | |
parent | 2567d6cf12ad25ae6f1bf7230d83c572e72ad49f (diff) | |
download | lua-cjson-439e03c6f9296ade78985a8d0b5c892846b6b06a.tar.gz lua-cjson-439e03c6f9296ade78985a8d0b5c892846b6b06a.tar.bz2 lua-cjson-439e03c6f9296ade78985a8d0b5c892846b6b06a.zip |
Add MIT license and update lua_cjson.c caveats
-rw-r--r-- | LICENSE | 20 | ||||
-rw-r--r-- | lua_cjson.c | 52 | ||||
-rw-r--r-- | strbuf.c | 24 | ||||
-rw-r--r-- | strbuf.h | 24 |
4 files changed, 102 insertions, 18 deletions
@@ -0,0 +1,20 @@ | |||
1 | Copyright (c) 2010-2011 Mark Pulford <mark@kyne.com.au> | ||
2 | |||
3 | Permission is hereby granted, free of charge, to any person obtaining | ||
4 | a copy of this software and associated documentation files (the | ||
5 | "Software"), to deal in the Software without restriction, including | ||
6 | without limitation the rights to use, copy, modify, merge, publish, | ||
7 | distribute, sublicense, and/or sell copies of the Software, and to | ||
8 | permit persons to whom the Software is furnished to do so, subject to | ||
9 | the following conditions: | ||
10 | |||
11 | The above copyright notice and this permission notice shall be | ||
12 | included in all copies or substantial portions of the Software. | ||
13 | |||
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
diff --git a/lua_cjson.c b/lua_cjson.c index de67766..379ea23 100644 --- a/lua_cjson.c +++ b/lua_cjson.c | |||
@@ -1,25 +1,41 @@ | |||
1 | /* Lua JSON routines | 1 | /* CJSON - JSON support for Lua |
2 | * | ||
3 | * Copyright (c) 2010-2011 Mark Pulford <mark@kyne.com.au> | ||
4 | * | ||
5 | * Permission is hereby granted, free of charge, to any person obtaining | ||
6 | * a copy of this software and associated documentation files (the | ||
7 | * "Software"), to deal in the Software without restriction, including | ||
8 | * without limitation the rights to use, copy, modify, merge, publish, | ||
9 | * distribute, sublicense, and/or sell copies of the Software, and to | ||
10 | * permit persons to whom the Software is furnished to do so, subject to | ||
11 | * the following conditions: | ||
12 | * | ||
13 | * The above copyright notice and this permission notice shall be | ||
14 | * included in all copies or substantial portions of the Software. | ||
15 | * | ||
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
19 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
20 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
21 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
22 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
2 | */ | 23 | */ |
3 | 24 | ||
4 | /* Caveats: | 25 | /* Caveats: |
5 | * - Assumes strings are valid UTF-8 and mostly treats them as opaque | 26 | * - JSON "null" values are represented as lightuserdata since Lua |
6 | * binary data. Will not throw an exception on bad data. | 27 | * tables cannot contain "nil". Compare with cjson.null. |
7 | * - Will decode \uXXXX escapes, but leaves high codepoints as UTF-8 | 28 | * - Only standard JSON escapes and \u0000 are used when encoding |
8 | * when encoding. | 29 | * JSON. Most unprintable characters are not escaped. |
9 | * - JSON "null" values are represented as lightuserdata. Compare with | 30 | * - Invalid UTF-8 characters are not detected and will be passed |
10 | * json.null. | 31 | * untouched. |
11 | * - Parsing comments is not supported. According to json.org, this isn't | 32 | * - Cannot parse NaN/Inf numbers when strict_numbers has been disabled. |
12 | * part of the spec. | 33 | * - Javascript comments are not part of the JSON spec, and are not |
13 | * - Parser accepts number formats beyond the JSON spec. | 34 | * supported. |
14 | * | 35 | * |
15 | * Note: lua_json_decode() probably spends significant time rehashing | 36 | * Note: Decoding is slower than encoding. Lua probably spends |
16 | * tables since it is difficult to know their size ahead of time. | 37 | * significant time rehashing tables when parsing JSON since it is |
17 | * Earlier JSON libaries didn't have this problem but the intermediate | 38 | * difficult to know object/array sizes ahead of time. |
18 | * storage (and their implementations) were much slower anyway.. | ||
19 | */ | ||
20 | |||
21 | /* FIXME: | ||
22 | * - Option to encode non-printable characters? Only \" \\ are required | ||
23 | */ | 39 | */ |
24 | 40 | ||
25 | #include <assert.h> | 41 | #include <assert.h> |
@@ -1,3 +1,27 @@ | |||
1 | /* strbuf - string buffer routines | ||
2 | * | ||
3 | * Copyright (c) 2010-2011 Mark Pulford <mark@kyne.com.au> | ||
4 | * | ||
5 | * Permission is hereby granted, free of charge, to any person obtaining | ||
6 | * a copy of this software and associated documentation files (the | ||
7 | * "Software"), to deal in the Software without restriction, including | ||
8 | * without limitation the rights to use, copy, modify, merge, publish, | ||
9 | * distribute, sublicense, and/or sell copies of the Software, and to | ||
10 | * permit persons to whom the Software is furnished to do so, subject to | ||
11 | * the following conditions: | ||
12 | * | ||
13 | * The above copyright notice and this permission notice shall be | ||
14 | * included in all copies or substantial portions of the Software. | ||
15 | * | ||
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
19 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
20 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
21 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
22 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
23 | */ | ||
24 | |||
1 | #include <stdio.h> | 25 | #include <stdio.h> |
2 | #include <stdlib.h> | 26 | #include <stdlib.h> |
3 | #include <stdarg.h> | 27 | #include <stdarg.h> |
@@ -1,3 +1,27 @@ | |||
1 | /* strbuf - String buffer routines | ||
2 | * | ||
3 | * Copyright (c) 2010-2011 Mark Pulford <mark@kyne.com.au> | ||
4 | * | ||
5 | * Permission is hereby granted, free of charge, to any person obtaining | ||
6 | * a copy of this software and associated documentation files (the | ||
7 | * "Software"), to deal in the Software without restriction, including | ||
8 | * without limitation the rights to use, copy, modify, merge, publish, | ||
9 | * distribute, sublicense, and/or sell copies of the Software, and to | ||
10 | * permit persons to whom the Software is furnished to do so, subject to | ||
11 | * the following conditions: | ||
12 | * | ||
13 | * The above copyright notice and this permission notice shall be | ||
14 | * included in all copies or substantial portions of the Software. | ||
15 | * | ||
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
19 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
20 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
21 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
22 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
23 | */ | ||
24 | |||
1 | #include <stdlib.h> | 25 | #include <stdlib.h> |
2 | #include <stdarg.h> | 26 | #include <stdarg.h> |
3 | 27 | ||