Repository: napalm-automation/napalm

Issue:
Junos "| display json" in cli method
### Description of Issue/Question
I would like to be able to run arbitrary show commands on junos and get the JSON or XML data back instead of stdout
It seems like junos.py isn't setup for handling "| display" and just drops it
Is that something you'd consider adding support for?

The way NX-OS SSH works I am able to do the above equivalent

*Note*: Please check https://guides.github.com/features/mastering-markdown/
to see how to properly format your request.

### Did you follow the steps from https://github.com/napalm-automation/napalm#faq
(Place an ``x`` between the square brackets where applicable)

- [x] Yes
- [] No


### Setup

### napalm version
(Paste verbatim output from `pip freeze | grep napalm` between quotes below)

```
napalm==3.3.1
```

### Network operating system version
(Paste verbatim output from `show version` - or equivalent - between quotes below)

```
Junos: 20.2R3-S2.5
```

### Steps to Reproduce the Issue
If I run "show lacp interfaces | display json" it doesn't honor the format request

```
>>> device.cli(['show lacp interfaces | display json'])
{'show lacp interfaces | display json': '\nAggregated interface: ae10\n    LACP state:       Role   Exp   Def  Dist  Col  Syn  Aggr  Timeout  Activity\n      xe-1/2/0       Actor    No    No   Yes  Yes  Yes   Yes     Fast    Active\n      xe-1/2/0     Partner    No    No   Yes  Yes  Yes   Yes     Fast    Active\n      xe-1/2/1       Actor    No    No   Yes  Yes  Yes   Yes     Fast    Active\n      xe-1/2/1     Partner    No    No   Yes  Yes  Yes   Yes     Fast    Active\n      xe-0/2/0       Actor    No    No   Yes  Yes  Yes   Yes     Fast    Active\n      xe-0/2/0     Partner    No    No   Yes  Yes  Yes   Yes     Fast    Active\n      xe-0/2/1       Actor    No    No   Yes  Yes  Yes   Yes     Fast    Active\n      xe-0/2/1     Partner    No    No   Yes  Yes  Yes   Yes     Fast    Active\n      xe-2/2/0       Actor    No    No   Yes  Yes  Yes   Yes     Fast    Active\n      xe-2/2/0     Partner    No    No   Yes  Yes  Yes   Yes     Fast    Active\n      xe-2/2/1       Actor    No    No   Yes  Yes  Yes   Yes     Fast    Active\n      xe-2/2/1     Partner    No    No   Yes  Yes  Yes   Yes     Fast    Active\n    LACP protocol:        Receive State  Transmit State          Mux State \n      xe-1/2/0                  Current   Fast periodic Collecting distributing\n      xe-1/2/1                  Current   Fast periodic Collecting distributing\n      xe-0/2/0                  Current   Fast periodic Collecting distributing\n      xe-0/2/1                  Current   Fast periodic Collecting distributing\n      xe-2/2/0                  Current   Fast periodic Collecting distributing\n      xe-2/2/1                  Current   Fast periodic Collecting distributing\n'}
```

### Error Traceback
(Paste the complete traceback of the exception between quotes below)

```

```



Discussion:

Resolving patch:
diff --git a/napalm/junos/junos.py b/napalm/junos/junos.py
--- a/napalm/junos/junos.py
+++ b/napalm/junos/junos.py
@@ -1014,7 +1014,7 @@ def get_lldp_neighbors_detail(self, interface=""):
 
     def cli(self, commands, encoding="text"):
         """Execute raw CLI commands and returns their output."""
-        if encoding not in ("text",):
+        if encoding not in ("text", "json", "xml"):
             raise NotImplementedError("%s is not a supported encoding" % encoding)
         cli_output = {}
 
@@ -1134,7 +1134,7 @@ def _process_pipe(cmd, txt):
                     base=exploded_cmd[0], pipes=" | ".join(command_safe_parts)
                 )
             )
-            raw_txt = self.device.cli(safe_command, warning=False)
+            raw_txt = self.device.cli(safe_command, warning=False, format=encoding)
             if isinstance(raw_txt, etree._Element):
                 raw_txt = etree.tostring(raw_txt.get_parent()).decode()
                 cli_output[str(command)] = raw_txt


Test patch: