Returns a JSON representing the packet. Please note that this cannot be used for bijective usage: data loss WILL occur, so it will not make sense to try to rebuild the packet from the output. This must only be used for a grepping/displaying purpose.
(self)
| 1794 | return c |
| 1795 | |
| 1796 | def json(self): |
| 1797 | # type: () -> str |
| 1798 | """ |
| 1799 | Returns a JSON representing the packet. |
| 1800 | |
| 1801 | Please note that this cannot be used for bijective usage: data loss WILL occur, |
| 1802 | so it will not make sense to try to rebuild the packet from the output. |
| 1803 | This must only be used for a grepping/displaying purpose. |
| 1804 | """ |
| 1805 | dump = json.dumps({k: v for (k, v) in self._command(json=True)}) |
| 1806 | pc = self.payload.json() |
| 1807 | if pc: |
| 1808 | dump = dump[:-1] + ", \"payload\": %s}" % pc |
| 1809 | return dump |
| 1810 | |
| 1811 | |
| 1812 | class NoPayload(Packet): |