mirror of https://github.com/akheron/jansson
Refuse to dump other types than array and object as the root value
This commit is contained in:
parent
36530d8c25
commit
0428f48d19
|
@ -237,6 +237,9 @@ char *json_dumps(const json_t *json, uint32_t flags)
|
||||||
strbuffer_t strbuff;
|
strbuffer_t strbuff;
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
|
if(!json_is_array(json) && !json_is_object(json))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if(strbuffer_init(&strbuff))
|
if(strbuffer_init(&strbuff))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -254,6 +257,9 @@ char *json_dumps(const json_t *json, uint32_t flags)
|
||||||
|
|
||||||
int json_dumpf(const json_t *json, FILE *output, uint32_t flags)
|
int json_dumpf(const json_t *json, FILE *output, uint32_t flags)
|
||||||
{
|
{
|
||||||
|
if(!json_is_array(json) && !json_is_object(json))
|
||||||
|
return -1;
|
||||||
|
|
||||||
if(do_dump(json, flags, 0, dump_to_file, (void *)output))
|
if(do_dump(json, flags, 0, dump_to_file, (void *)output))
|
||||||
return -1;
|
return -1;
|
||||||
return dump_to_file("\n", 1, (void *)output);
|
return dump_to_file("\n", 1, (void *)output);
|
||||||
|
|
Loading…
Reference in New Issue