Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Add option to print JSON escaped from simple quotes #6700
Comments
|
Post an example URL that produces an invalid JSON. |
|
Actually the JSON is valid, but when I try to parse it in my code, it fails because of unescaped single quotes. EDIT: removed the code copied by mistake It falis with the error: "ValueError: Unterminated string starting at ..." |
|
There is no problem then. Just parse it properly with |
|
Oh, but I do that. I'm sorry, I copied the wrong part of the code.
Also, I think it's not possible to escape the thing from inside my code. That must be done during generation. |
|
|
|
Hum... I thought of that possibility, but I don't understand why that would happen. Also, to make sure it was a problem with unescaped characters, I copied the generated JSON and parsed it with in the javascript console. Again, it's valid JSON, but in javascript it returns a syntax error. Javascript console says Now, it works for However, there's no way to use the json in my code without parsing it... Do you see the problem here? In the first case, if the single quotes are escaped, it will work. |
|
Ok, I managed to fix this. Now it works! :) |
|
There is no need in PR since there is no problem.
|
|
Hum... It seems to me like you didn't understand what the problem here was. |
|
Post the full code you are using to parse it. |
|
Ok... this is part of code. Not the full code, cos that's 1339 loc.
|
|
The full code. How am I supposed to guess what |
Currently, if you want to use the JSON generated by -J option programatically, you're pretty fucked, because if there's a single quote (') in any part of the JSON, that won't allow you to parse the string.
Maybe make the -J option print the JSON with escaped single quotes by default?