cJSON_ConfigurationChangeFormat

This commit is contained in:
Max Bruckner
2018-02-03 02:32:17 +01:00
parent c4c52cfe58
commit 1d9d2e8673
3 changed files with 49 additions and 12 deletions

34
cJSON.c
View File

@ -2930,16 +2930,6 @@ CJSON_PUBLIC(cJSON_Configuration) cJSON_CreateConfiguration(const cJSON * const
/* then overwrite with other options if they exist */
option = get_object_item(json, "format", &global_configuration);
if (cJSON_IsTrue(option))
{
configuration->format = true;
}
else if (cJSON_IsFalse(option))
{
configuration->format = false;
}
option = get_object_item(json, "case_sensitive", &global_configuration);
if (cJSON_IsTrue(option))
{
@ -3018,6 +3008,30 @@ CJSON_PUBLIC(cJSON_Configuration) cJSON_ConfigurationChangePrebufferSize(cJSON_C
return configuration;
}
CJSON_PUBLIC(cJSON_Configuration) cJSON_ConfigurationChangeFormat(cJSON_Configuration configuration, cJSON_Format format)
{
if (configuration == NULL)
{
return NULL;
}
switch (format)
{
case CJSON_FORMAT_MINIFIED:
((internal_configuration*)configuration)->format = false;
break;
case CJSON_FORMAT_DEFAULT:
((internal_configuration*)configuration)->format = true;
break;
default:
return NULL;
}
return configuration;
}
static cJSON_bool compare(const cJSON * const a, const cJSON * const b, const internal_configuration * const configuration)
{
if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF)) || cJSON_IsInvalid(a))