You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Side note: I'm curious, are you tripping across this specific example, or is this a simplified version of something? Because in this case, I'd imagine you could just work around this by deleting the backslash?
I am using scrapy spider some web page . It contains js with json5 format. Got a lot of string like "http:\/\/abc\/". I don't sure json5 format deal with '\/'. With json5 parse is more comfortable.
Activity
dpranke commentedon Feb 25, 2019
Hi,
Thanks for the bug report. However, I don't think I understand what you're reporting.
You said "blash" in the subject, but your example is using forward slashes.
Also, if I test the example you give with the latest version of
it all seems to work like I'd expect. Are you using the latest version? Maybe I'm missing something?
sloanyyc commentedon Feb 26, 2019
json5.loads('{a:"a\/"}')
ValueError: :1 Unexpected "/" at column 7
such as 'http://domain/' can't jsonfiy
Sorry, bug git edit translate \/ as /
sloanyyc commentedon Feb 26, 2019
import json5
json5.VERSION
print(json5.loads(r'{a:"a\/"}'))
ValueError Traceback (most recent call last)
in
----> 1 print(json5.loads(r'{a:"a\/"}'))
~/venv/lib/python3.7/site-packages/json5/lib.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook)
57 ast, err, newpos = parser.parse()
58 if err:
---> 59 raise ValueError(err)
60
61 def _fp_constant_parser(s):
ValueError: :1 Unexpected "/" at column 7
dpranke commentedon Feb 26, 2019
Ah, got it. Yes, that looks like a bug.
Side note: I'm curious, are you tripping across this specific example, or is this a simplified version of something? Because in this case, I'd imagine you could just work around this by deleting the backslash?
sloanyyc commentedon Feb 26, 2019
I am using scrapy spider some web page . It contains js with json5 format. Got a lot of string like "http:\/\/abc\/". I don't sure json5 format deal with '\/'. With json5 parse is more comfortable.
Fix github issue #23, not parsing an escape char case properly.
Fix github issue #23, not parsing an escape char case properly.
dpranke commentedon Mar 8, 2019
Thanks for the bug report. This should be fixed now on master, v0.6-dev, and in v0.6.2, newly pushed to PyPI.
This also newly handles "\0" correctly, which it didn't before and which I noticed while digging into this.