On 9/24/19 4:32 PM, Julien Fortin wrote: > diff --git a/ip/iproute.c b/ip/iproute.c > index a4533851..5d5f1551 100644 > --- a/ip/iproute.c > +++ b/ip/iproute.c > @@ -649,23 +649,27 @@ static void print_rta_multipath(FILE *fp, const struct > rtmsg *r, > int len = RTA_PAYLOAD(rta); > int first = 1; > > + open_json_array(PRINT_JSON, "nexthops"); > + > while (len >= sizeof(*nh)) { > struct rtattr *tb[RTA_MAX + 1]; > > if (nh->rtnh_len > len) > break; > > + open_json_object(NULL); > + > if (!is_json_context()) {
With the fprintf removed in favor of print_string(PRINT_FP), you should be able to remove this is_json_context() check and remove a level of indentation for this section. > if ((r->rtm_flags & RTM_F_CLONED) && > r->rtm_type == RTN_MULTICAST) { > if (first) { > - fprintf(fp, "Oifs: "); > + print_string(PRINT_FP, NULL, "Oifs: ", > NULL); > first = 0; > } else { > - fprintf(fp, " "); > + print_string(PRINT_FP, NULL, " ", NULL); > } > } else > - fprintf(fp, "%s\tnexthop ", _SL_); > + print_string(PRINT_FP, NULL, "%s\tnexthop ", > _SL_); > } > > if (nh->rtnh_len > sizeof(*nh)) {