question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid JSON generated with rpc.get_config(options={'format': 'json'})

See original GitHub issue
>>>json.loads(dev.rpc.get_config(options={'format': 'json'}).text)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.5/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 22030 column 17 (char 680605)

Looking at the json from dev.rpc.get_config(options={'format': 'json'}).text it indeed is missing a ,:

22021         "protocols" : [
22022         {
22023             "comment" : "BEGIN: ROUTING-INSTANCES",
22024             "bgp" : [
22025             {
22026                 "apply-groups" : [
22027                 {
22028                     "data" : "BGP_DEFAULTS"
22029                 }
22030                 ]
22031                 "path-selection" : [
22032                 {
22033                     "always-compare-med" : [
22034                     {
22035                         "data" : null
22036                     }
22037                     ]
22038                 }
22039                 ],

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
stacywsmithcommented, Apr 18, 2017

Hi @CMeza99

Thanks for reporting. This appears to be a Junos bug in the rendering of the configuration in JSON format. If you want to provide more details here I can help in tracking the Junos issue. Alternatively, you can open a JTAC case.

I would need to know:

  1. Juniper platform/model
  2. Exact version of Junos
  3. CLI output of show configuration | display xml
  4. CLI output of show configuration | display json

FYI, you should not have to call json.loads() on the text of the RPC reply. Instead, when you request JSON format, PyEZ should perform the json.loads() for you and return a native Python data structure.

In this case, that’s not happening because the json.loads() is raising an exception because the JSON emitted by Junos is invalid. I spoke with @vnitinv about this and he will address this specific PyEZ issue.

0reactions
stacywsmithcommented, Apr 21, 2017

The primary problem in this issue is a Junos bug. The user is addressing the Junos bug through JTAC.

The secondary problem is that the PyEZ behavior for this error condition was confusing and unexpected. This secondary problem has been addressed through #706.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Json RPC to pysjonrpc throws invalid JSON response
I am developing an android app which connects a python server through JSON. I am now encountering a bug that hinders the connection...
Read more >
HH110: Invalid JSON-RPC response received: missing token ...
When I run yarn hardhat run scripts/deploy.js --network goerli , the following error is displayed in my terminal: HardhatError: HH110: Invalid ...
Read more >
How to Fix the Invalid JSON Response Error in WordPress
Go to Settings → Permalinks in your WordPress dashboard and click Save Changes. This will force WordPress to generate a new, clean .htaccess ......
Read more >
Solved: REST API / Invalid JSON Request
I dont get what there is been missing or where the error is? I didnt find anything through researches. Am I Missing the...
Read more >
Understanding the Request Procedure in a NETCONF Session
<rpc> < operational-request format="(ascii | json | json-minified | text | xml ... Operational command RPCs also support returning XML output in minified ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found