int heim_base2json(heim_object_t obj, void (*out)(char *, void *), void *ctx) { heim_tid_t type = heim_get_tid(obj); __block int fail = 0, needcomma = 0; switch (type) { case HEIM_TID_ARRAY: out("[ ", ctx); heim_array_iterate(obj, ^(heim_object_t sub) { if (needcomma) out(", ", ctx); fail |= heim_base2json(sub, out, ctx); needcomma = 1; }); out("]", ctx); break; case HEIM_TID_DICT: out("{ ", ctx); heim_dict_iterate(obj, ^(heim_object_t key, heim_object_t value) { if (needcomma) out(", ", ctx); fail |= heim_base2json(key, out, ctx); out(" = ", ctx); fail |= heim_base2json(value, out, ctx); needcomma = 1; });
/** * Dump a heimbase object to stderr (useful from the debugger!) * * @param obj object to dump using JSON or JSON-like format * * @addtogroup heimbase */ void heim_show(heim_object_t obj) { heim_base2json(obj, stderr, HEIM_JSON_F_NO_DATA_DICT, show_printf); }
void heim_show(heim_object_t obj) { heim_base2json(obj, stderr, show_printf); }