static ns_t *ns_fromjson (JSON o) { ns_t *ns = xzmalloc (sizeof (*ns)); if (!Jget_nodeset (o, "ok", &ns->ok) || !Jget_nodeset (o, "unknown", &ns->unknown) || !Jget_nodeset (o, "slow", &ns->slow) || !Jget_nodeset (o, "fail", &ns->fail)) { ns_destroy (ns); return NULL; } return ns; }
static ns_t *ns_fromjson (const char *json_str) { ns_t *ns = xzmalloc (sizeof (*ns)); JSON o = NULL; if (!(o = Jfromstr (json_str)) || !Jget_nodeset (o, "ok", &ns->ok) || !Jget_nodeset (o, "unknown", &ns->unknown) || !Jget_nodeset (o, "slow", &ns->slow) || !Jget_nodeset (o, "fail", &ns->fail)) { ns_destroy (ns); ns = NULL; } Jput (o); return ns; }