Now object's names and values and array's items are allocated (with starting capacity) only after first item is added.
This will prevent wasting memory when parsing empty objects and arrays.
Details:
- Fixed bug, where json_object_nget_value returned wrong values.
- json_object_get_count returns a number of object's name-value pairs.
- json_object_get_name returns a name at a specific index.
- Both functions allow iterating over every value in a object.
- Changed max capacity for JSON_Array and JSON_Object (they're not equal anymore).
- Added functions to resize object and array, which are also used after parsing to "trim" them to their real lengths.
- Added try_realloc function.
- Added SUCCESS and ERROR macros to make code more readable.
- Code cleanup.
Details:
- Increased STARTING_CAPACITY from 10 to 15.
- Added 2 macros: skip_char and skip_whitespaces.
- Added json_object_nget_value function, which removes neccessity to allocate new string when using dotget functions.
- Removed parson_strdup function, it was called only once and could be easilly replaced with appropriate call to parson_strndup.
- Renamed skip_string to skip_quotes, which is a more appropriate name, and made it work on a passed pointer to a string, which is much like skip_char and skip_whitespaces.
- Removed copy_and_remove_whitespaces, it was unncessary, and could be easily replaced with skip_whitepsaces macro.
- Merged parse_escaped_characters and get_string to get_processed_string, which makes more sense.
- Changed is_decimal implementation, to avoid unncessary string duplicating.
- Removed string copying in parse_number value and json_parse_string, since it was unncessary.
Removed redundant typedefs, renamed JSON_value_t to JSON_Value_Type and JSON_value_value to JSON_Value_Value to make names more consistent across project. Added project's name and url above license.