Simplify things by storing integer values only as int64_t's internally, and

omit the range check during parsing since we already have the checks when
 accessing the value. There is no longer a json_type_int64, only json_type_int.
Fix some problems with parsing 0 and -0 values, and add a couple of tests.
Fix some minor compile issues on HPUX environments.


git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@60 327403b1-1117-474d-bef2-5cb71233fd97
This commit is contained in:
ehaszla
2010-12-07 18:15:35 +00:00
parent f1ae67dbf0
commit 252669cee6
8 changed files with 43 additions and 41 deletions

View File

@@ -47,7 +47,6 @@ typedef enum json_type {
json_type_object,
json_type_array,
json_type_string,
json_type_int64
} json_type;
/* reference counting functions */
@@ -75,7 +74,6 @@ extern void json_object_put(struct json_object *obj);
json_type_object,
json_type_array,
json_type_string,
json_type_int64,
*/
extern int json_object_is_type(struct json_object *obj, enum json_type type);
@@ -89,7 +87,6 @@ extern int json_object_is_type(struct json_object *obj, enum json_type type);
json_type_object,
json_type_array,
json_type_string,
json_type_int64,
*/
extern enum json_type json_object_get_type(struct json_object *obj);
@@ -252,15 +249,17 @@ extern boolean json_object_get_boolean(struct json_object *obj);
/* int type methods */
/** Create a new empty json_object of type json_type_int
* Note that values are stored as 64-bit values internally.
* To ensure the full range is maintained, use json_object_new_int64 instead.
* @param i the integer
* @returns a json_object of type json_type_int
*/
extern struct json_object* json_object_new_int(int32_t i);
/** Create a new empty json_object of type json_type_int64
/** Create a new empty json_object of type json_type_int
* @param i the integer
* @returns a json_object of type json_type_int64
* @returns a json_object of type json_type_int
*/
extern struct json_object* json_object_new_int64(int64_t i);
@@ -271,6 +270,10 @@ extern struct json_object* json_object_new_int64(int64_t i);
* double objects will return their integer conversion. Strings will be
* parsed as an integer. If no conversion exists then 0 is returned.
*
* Note that integers are stored internally as 64-bit values.
* If the value of too big or too small to fit into 32-bit, INT32_MAX or
* INT32_MIN are returned, respectively.
*
* @param obj the json_object instance
* @returns an int
*/