]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Do not escape forward slashes for `show ip route json`
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Sat, 3 Jul 2021 11:09:28 +0000 (14:09 +0300)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Sat, 3 Jul 2021 11:19:48 +0000 (14:19 +0300)
Basically, this is handled by JSON-C library. I've compiled with the
latest release of json-c and it works well.

Didn't test with various distribution versions, but this change is kinda
dependend from the json-c lib version the distra has.

Before:
```
  "192.168.100.1\/32":[
    {
      "prefix":"192.168.100.1\/32",
```

After:
```
  "192.168.100.1/32":[
    {
      "prefix":"192.168.100.1/32",
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
zebra/zebra_vty.c

index 51f19a3c03f91b4b76130843ef2bda80a63d2841..8cf783341cbfc4b7b4b236492bb6e30739578468 100644 (file)
@@ -1121,8 +1121,10 @@ static void vty_show_ip_route_detail_json(struct vty *vty,
 
        prefix2str(&rn->p, buf, sizeof(buf));
        json_object_object_add(json, buf, json_prefix);
-       vty_out(vty, "%s\n", json_object_to_json_string_ext(
-                                            json, JSON_C_TO_STRING_PRETTY));
+       vty_out(vty, "%s\n",
+               json_object_to_json_string_ext(
+                       json, JSON_C_TO_STRING_PRETTY
+                                     | JSON_C_TO_STRING_NOSLASHESCAPE));
        json_object_free(json);
 }
 
@@ -1234,8 +1236,11 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf,
        }
 
        if (use_json) {
-               vty_out(vty, "%s\n", json_object_to_json_string_ext(json,
-                                               JSON_C_TO_STRING_PRETTY));
+               vty_out(vty, "%s\n",
+                       json_object_to_json_string_ext(
+                               json,
+                               JSON_C_TO_STRING_PRETTY
+                                       | JSON_C_TO_STRING_NOSLASHESCAPE));
                json_object_free(json);
        }
 }