2 * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
4 * Jansson is free software; you can redistribute it and/or modify
5 * it under the terms of the MIT license. See LICENSE for details.
17 /* Encode an empty object/array, add an item, encode again */
20 result = json_dumps(json, 0);
21 if(!result || strcmp(result, "{}"))
22 fail("json_dumps failed");
24 json_object_set_new(json, "foo", json_integer(5));
25 result = json_dumps(json, 0);
26 if(!result || strcmp(result, "{\"foo\": 5}"))
27 fail("json_dumps failed");
32 result = json_dumps(json, 0);
33 if(!result || strcmp(result, "[]"))
34 fail("json_dumps failed");
37 json_array_append_new(json, json_integer(5));
38 result = json_dumps(json, 0);
39 if(!result || strcmp(result, "[5]"))
40 fail("json_dumps failed");