Commit Graph

44 Commits

Author SHA1 Message Date
Petri Lehtinen
579c291882 Expand the pack/unpack API, implement unpack flags
Expand the pack/unpack API: json_(un)pack is the simple version with
no error output, json_(un)pack_ex has error output and flags,
json_v(un)pack_ex is a va_list version of json_(un)pack_ex.

Implement unpacking flags:

- JSON_UNPACK_ONLY turns off extra validation, i.e. array and object
  unpacking doesn't check that all items are unpacked. This is really
  just convenience for not adding '*' after each object and array.

- JSON_VALIDATE_ONLY turns off unpacking, i.e. no varargs are expected
  and nothing is unpacked.
2011-01-25 10:02:27 +02:00
Petri Lehtinen
fa7c2ea070 Update copyright notices for 2011 2011-01-22 13:43:14 +02:00
Petri Lehtinen
23bc8e468d Add version info to jansson.h 2010-12-14 20:58:40 +02:00
Petri Lehtinen
5422a862de Enhance error reporting
This patch adds two new fields to the json_error_t struct: column and
source. It also adds functions to populate json_error_t internally.

The column field is not currently used, but it will be utilized in the
decoder and pack/unpack functions.
2010-10-27 21:58:20 +03:00
Petri Lehtinen
bb5d4efb2e Make json_error_t transparent again
After looking at the new code for a few days, I didn't like it
anymore. To prepare for the future, a few fields will be added to the
json_error_t struct later.

This reverts commit 23dd078c8d. Some
adjustments were needed because of newer commits.
2010-10-26 21:20:34 +03:00
Graeme Smecher
198d537be7 Adds json_pack / json_unpack variadic functions. 2010-10-26 08:59:06 +03:00
Petri Lehtinen
23dd078c8d Make json_error_t opaque
All decoding functions now accept a json_error_t** parameter and set
it to point to a heap-allocated json_error_t structure if an error
occurs. The contents of json_error_t are no longer exposed directly, a
few functions to do it have been added instead. If an error occurs,
the user must free the json_error_t value.

This makes it possible to enhance the error reporting facilities in
the future without breaking ABI compatibility with older versions.

This is a backwards incompatible change.
2010-10-14 21:02:37 +03:00
Petri Lehtinen
56643d4311 Merge branch '1.3'
Conflicts:
	doc/apiref.rst
	src/jansson_private.h
2010-08-14 21:02:08 +03:00
Petri Lehtinen
bfac1972e2 Add a flags parameter to all decoding functions for future needs
As of now, the parameter is unused, but may be needed in the future.
I'm adding it now so that in the future both API and ABI remain
backwards compatible as long as possible.

This is a backwards incompatible change.
2010-08-14 17:28:09 +03:00
Petri Lehtinen
f8d0e01e46 Change the maximum indentation size to 32 spaces in encoder
This is to free up bits from the flags parameter of json_dump
functions. I'm pretty sure no-one needs 256 spaces of indentation when
pretty-printing JSON values...

This is a backwards incompatible change.
2010-08-13 22:12:36 +03:00
Petri Lehtinen
ffbab6fedd Change the underlying type of JSON integer from long to json_int_t
json_int_t is typedef'd to long long if it's supported, or long
otherwise. There's also some supporting things, like the
JSON_INTEGER_FORMAT macro that expands to the printf() conversion
specifier that corresponds to json_int_t's actual type.

This is a backwards incompatible change.
2010-08-13 22:07:20 +03:00
Petri Lehtinen
7ce70533c9 Move site configuration to jansson_config.h
This way, more site configuration can be more easily added later.
2010-08-10 22:16:55 +03:00
Petri Lehtinen
29ee3832cf Support compilers that don't have the "inline" keyword
Use AC_C_INLINE autoconf macro, include config.h where needed, and add
a define of JSON_INLINE to jansson.h that has the correct "inline"
keyword.
2010-03-28 21:14:08 +03:00
Petri Lehtinen
08dc8d9baf Add year 2010 to copyright notices 2010-02-02 21:26:11 +02:00
Petri Lehtinen
9db34dc31a Add functions for shallow and deep copying JSON values 2009-12-31 18:50:39 +02:00
Petri Lehtinen
95a468cebb Add equality test for JSON values 2009-12-31 18:50:36 +02:00
Petri Lehtinen
dd2fe1ebe8 Add _nocheck functions
Added functions are:

* json_string_nocheck()
* json_string_set_nocheck()
* json_object_set_nocheck()
* json_object_set_new_nocheck()

These functions don't check that their string argument is valid UTF-8,
but assume that the user has already performed the check.
2009-12-23 22:28:24 +02:00
Petri Lehtinen
6637b976ed Merge branch '1.1' 2009-12-21 14:13:05 +02:00
Petri Lehtinen
f5202bedef Remove const qualifier from the json_t parameter in json_*_set() functions.
It's incorrect as these functions modify the value.
2009-12-21 14:12:06 +02:00
Petri Lehtinen
19a606d736 Implement JSON_SORT_KEYS encoding flag
With this flag, the objects are sorted by key when encoding.
2009-12-16 23:12:39 +02:00
Petri Lehtinen
50031440a3 Implement JSON_ENSURE_ASCII encoding flag
With this flag, all Unicode characters outside the ASCII range are
escaped.
2009-12-05 22:55:30 +02:00
Petri Lehtinen
e0a88d19d1 Merge branch '1.1'
Conflicts:
	configure.ac
	doc/conf.py
2009-11-08 22:01:02 +02:00
Petri Lehtinen
ca6d26a1c2 Don't include stdint.h in jansson.h
It's not needed
2009-11-07 14:45:46 +02:00
Petri Lehtinen
f236c14dc5 dump: Revise whitespace usage
- Never append newline to output
- By default, add spaces between array and object items for more
  readable output
- Introduce the flag JSON_COMPACT to not add the aforementioned spaces
2009-11-04 22:09:40 +02:00
raoulh
a83cd30c31 Add C++ guards to jansson.h
Signed-off-by: Petri Lehtinen <petri@digip.org>
2009-10-19 12:22:21 +03:00
Petri Lehtinen
951d091f07 Make integer, real and string mutable
Added functions:

  json_string_set
  json_integer_set
  json_real_set

While at it, clarify the documentation and parameter naming of
json_{string,integer,real}_value() a bit.
2009-10-14 08:23:02 +03:00
Petri Lehtinen
1e00cd58a5 Extend object API
Added functions:

  json_object_size
  json_object_clear
  json_object_update
2009-10-11 20:44:01 +03:00
Petri Lehtinen
cbacac5975 Extend array API
Added functions:

  json_array_insert
  json_array_insert_new
  json_array_remove
  json_array_clear
  json_array_extend
2009-09-29 22:17:58 +03:00
Petri Lehtinen
743af38e7f Use unsigned long instead of uint32_t
Some day we will have ANSI C compatibility... This change doesn't make
the API backwards incompatible because uint32_t was only used in flags
to json_dump*() and the flags are meant to be used only by ORing
constants and macro output, and actually currently only JSON_INDENT
can be used.
2009-09-13 13:16:34 +03:00
Petri Lehtinen
7ee974e91c Don't perform reference counting on true, false and null
This makes their constructors thread safe. A special reference count
-1 is used to test whether to perform reference counting on a value or
not.
2009-09-07 21:40:14 +03:00
Petri Lehtinen
fd259ff68c Merge branch '1.0'
Conflicts:
	configure.ac
	doc/conf.py
2009-09-06 12:53:38 +03:00
Petri Lehtinen
78eda92908 jansson.h: Fix typo
json_is_true was spelled jsin_is_true. Quite fatal.
2009-09-04 15:21:00 +03:00
Petri Lehtinen
89d09813c3 Add reference stealing functions for inserting values to objects and arrays
The non-stealing functions are now just simple wrappers around these.
2009-09-04 09:52:37 +03:00
Petri Lehtinen
36530d8c25 Remove unimplemented json_clone() 2009-07-30 11:32:27 +03:00
Petri Lehtinen
08d712d038 Add macro json_is_boolean 2009-07-30 11:32:27 +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
1f65a3cae7 Get rid of JSON_SORT_KEYS dump flag
Object sorting will be implemented later.
2009-07-13 23:38:04 +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
b724c2b122 Separate integers and real numbers 2009-07-04 13:19:25 +03:00
Petri Lehtinen
d135a80e07 Implement json_load, json_loadf and json_loadfd 2009-06-15 13:53:50 +03:00
Petri Lehtinen
d1407bed3a Implement dumping to an fd 2009-05-16 15:15:01 +03:00
Petri Lehtinen
fdcf28b667 Refactor error reporting 2009-05-13 22:25:34 +03:00
Petri Lehtinen
86e1481cdb Get rid of include/ 2009-05-12 22:07:50 +03:00