Commit Graph

18 Commits

Author SHA1 Message Date
Petri Lehtinen
98a8c1aebf Don't include unistd.h
It's not needed.
2009-09-06 22:24:22 +03:00
Petri Lehtinen
9611780907 dump: Optimize indenting
Don't alloca() a whitespace buffer and fill it with spaces in each
call to dump_indent. Instead, use a static whitespace buffer.

As a bonus, this saves the use of poorly portable alloca().
2009-09-04 09:52:40 +03:00
Petri Lehtinen
0428f48d19 Refuse to dump other types than array and object as the root value 2009-08-04 20:58:02 +03:00
Petri Lehtinen
2f4d6f8ae7 Add LICENSE and a copyright note to all sources 2009-07-30 11:32:24 +03:00
Petri Lehtinen
f41e380984 Rename json_{load,dump} to json_{load,dump}_file 2009-07-28 10:58:13 +03:00
Petri Lehtinen
b348519e96 Fix some memory leaks and invalid memory references 2009-07-28 10:38:21 +03:00
Petri Lehtinen
4c414bdd6d Get rid of json_dumpfd and json_loadfd
fdopen() makes supporting separate API for file descriptors useless.
Supporting fd's also makes Jansson less portable.
2009-07-13 21:45:16 +03:00
Petri Lehtinen
68e948f567 Don't dump extra spaces when indenting 2009-07-09 21:01:43 +03:00
Petri Lehtinen
6b14df13cc Fix dumping of Unicode control codes
Inside strings, All UTF-8 characters except for \, " and Unicode
control codes are dumped as-is. The control codes that have a special
one-character escape use that escape, and other control codes are
dumped using the \uXXXX escape.
2009-07-09 20:59:52 +03:00
Petri Lehtinen
4384776776 Fix empty array dumping 2009-07-04 13:19:41 +03:00
Petri Lehtinen
b724c2b122 Separate integers and real numbers 2009-07-04 13:19:25 +03:00
Petri Lehtinen
b1fe723a7f Fix json_loadf and json_loadfd with empty input
Nothing was appended to strbuffer, so the buffer was left empty. An
empty strbuffer is not an empty string but NULL, so the result was a
segfault.

This patch fixes the problem by initializing strbuffer to an empty
string.
2009-06-30 13:55:20 +03:00
Petri Lehtinen
8c697312e4 strbuffer_value: Return a read-only pointer rather than duplicating the value 2009-06-13 22:27:23 +03:00
Petri Lehtinen
197d3aa160 Implement strbuffer
String buffer (strbuffer) is an object that resizes automatically when
data is added to it. It was implemented by generalizing the technique
used in json_dumps().
2009-06-11 08:56:11 +03:00
Petri Lehtinen
7764f3f321 Implement json_dump and json_dumps 2009-06-09 22:37:31 +03:00
Petri Lehtinen
d1407bed3a Implement dumping to an fd 2009-05-16 15:15:01 +03:00
Petri Lehtinen
9ea51b2855 Implement dumping to file 2009-05-12 21:44:45 +03:00
Petri Lehtinen
17a69c2d66 Initial import 2009-05-12 21:44:01 +03:00