- if (tr_cmp_timespec(trp_route_get_expiry(route), &ts_zero) == 0) {
- expires = strdup("");
- } else {
- expires = timespec_to_str(route->expiry);
- if (expires == NULL) {
- json_decref(route_json);
- return NULL;
- }
- }
+ OBJECT_SET_OR_FAIL(route_json, "community", tr_name_to_json_string(trp_route_get_comm(route)));
+ OBJECT_SET_OR_FAIL(route_json, "realm", tr_name_to_json_string(trp_route_get_realm(route)));
+ OBJECT_SET_OR_FAIL(route_json, "peer", tr_name_to_json_string(trp_route_get_peer(route)));
+ OBJECT_SET_OR_FAIL(route_json, "metric", json_integer(trp_route_get_metric(route)));
+ OBJECT_SET_OR_FAIL(route_json, "trust_router", tr_name_to_json_string(trp_route_get_trust_router(route)));
+ OBJECT_SET_OR_FAIL(route_json, "next_hop", tr_name_to_json_string(trp_route_get_next_hop(route)));
+ OBJECT_SET_OR_FAIL(route_json, "selected", json_boolean(trp_route_is_selected(route)));
+ OBJECT_SET_OR_FAIL(route_json, "local", json_boolean(trp_route_is_local(route)));
+ OBJECT_SET_OR_FAIL(route_json, "expires", expiry_to_json_string(route));
+
+ /* succeeded - set the return value and increment the reference count */
+ retval = route_json;
+ json_incref(retval);