+0.4
+ * Fix additional error case in object parsing
+ * Add back sign reversal in nested object parse as error pointer
+ value is negative, while error value is positive.
+ Michael Clark <michael@metaparadigm.com>
+
0.3
* fix pointer arithmetic bug for error pointer check in is_error() macro
* fix type passed to printbuf_memappend in json_tokener
</head>\r
<body>\r
<h2>JSON-C - A JSON implementation in C</h2>\r
- <p>Latest release: <a href="json-c-0.3.tar.gz">json-c-0.3.tar.gz</a></p>\r
+ <p>Latest release: <a href="json-c-0.4.tar.gz">json-c-0.4.tar.gz</a></p>\r
<p>JSON-C implements a reference counting object model that allows you to easily \r
construct JSON objects in C, output them as JSON formatted strings and parse \r
JSON formatted strings back into the C representation of JSON objects.</p>\r
/*
- * $Id: json_tokener.c,v 1.15 2005/07/15 03:19:43 mclark Exp $
+ * $Id: json_tokener.c,v 1.17 2005/07/26 07:49:11 mclark Exp $
*
* Copyright Metaparadigm Pte. Ltd. 2004.
* Michael Clark <michael@metaparadigm.com>
} else {
obj = json_tokener_do_parse(this);
if(is_error(obj)) {
- err = (enum json_tokener_error)obj;
+ err = -(enum json_tokener_error)obj;
goto out;
}
json_object_array_add(current, obj);
printbuf_reset(this->pb);
state = json_tokener_state_object_field;
start_offset = ++this->pos;
+ } else {
+ err = json_tokener_error_parse_object;
+ goto out;
}
break;
case json_tokener_state_object_value:
obj = json_tokener_do_parse(this);
if(is_error(obj)) {
- err = (enum json_tokener_error)obj;
+ err = -(enum json_tokener_error)obj;
goto out;
}
json_object_object_add(current, obj_field_name, obj);
mc_debug("json_tokener_do_parse: error=%d state=%d char=%c\n",
err, state, c);
json_object_put(current);
- return error_ptr((ptrdiff_t)-err);
+ return error_ptr(-err);
}
printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
json_object_put(new_obj);
+ new_obj = json_tokener_parse("{ foo }");
+ if(is_error(new_obj)) printf("got error as expected\n");
+
new_obj = json_tokener_parse("foo");
if(is_error(new_obj)) printf("got error as expected\n");