diff options
Diffstat (limited to 'src/jplist.c')
| -rw-r--r-- | src/jplist.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/jplist.c b/src/jplist.c index d12540e..f4adf2f 100644 --- a/src/jplist.c +++ b/src/jplist.c | |||
| @@ -395,6 +395,11 @@ PLIST_API int plist_to_json(plist_t plist, char **json, uint32_t* length, int pr | |||
| 395 | return PLIST_ERR_INVALID_ARG; | 395 | return PLIST_ERR_INVALID_ARG; |
| 396 | } | 396 | } |
| 397 | 397 | ||
| 398 | if (!PLIST_IS_DICT(plist) && !PLIST_IS_ARRAY(plist)) { | ||
| 399 | PLIST_JSON_WRITE_ERR("plist data is not valid for JSON format\n"); | ||
| 400 | return PLIST_ERR_FORMAT; | ||
| 401 | } | ||
| 402 | |||
| 398 | res = node_estimate_size(plist, &size, 0, prettify); | 403 | res = node_estimate_size(plist, &size, 0, prettify); |
| 399 | if (res < 0) { | 404 | if (res < 0) { |
| 400 | return res; | 405 | return res; |
| @@ -413,6 +418,9 @@ PLIST_API int plist_to_json(plist_t plist, char **json, uint32_t* length, int pr | |||
| 413 | *length = 0; | 418 | *length = 0; |
| 414 | return res; | 419 | return res; |
| 415 | } | 420 | } |
| 421 | if (prettify) { | ||
| 422 | str_buf_append(outbuf, "\n", 1); | ||
| 423 | } | ||
| 416 | 424 | ||
| 417 | str_buf_append(outbuf, "\0", 1); | 425 | str_buf_append(outbuf, "\0", 1); |
| 418 | 426 | ||
