Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON parsing fails too hard #7285

Open
Timeroot opened this issue Mar 1, 2024 · 1 comment
Open

JSON parsing fails too hard #7285

Timeroot opened this issue Mar 1, 2024 · 1 comment

Comments

@Timeroot
Copy link

Timeroot commented Mar 1, 2024

Description

Although the JSON spec does not allow comments, plenty of JSON files have comments in them anyway, e.g.

{
  "serverlist":
   ["us-east-1","us-west-1","sea-2"],
//must be a string not an integer
  "userid": "13317025461942"
}

and plenty of parsers accept (and ignore) these. In Jupyter 6.x, this was fine, and we could edit our .JSON files in Jupyter as a text editor. In Jupyter 7, it seems that the JSON parsing has gotten "smarter". While that's fine and well, it then refuses to give a basic text editor.

The user is just met with "JSON.parse: expected property name or '}' at line 2 column 1 of the JSON data" if there's a comment on the second line. And then no editing functionality is available at all, not even just to fix the file. The only option is to rename the file to .txt, edit like that, and then move the file back to .json.

Reproduce

Create a file named "foo.json" with the body

{
//hi
"a":5}

and open it in Jupyter. Jupyter gives a parse error and then displays no editor.

Expected behavior

Jupyter should give a fallback plain-text editor.

Context

$ jupyter --version Selected Jupyter core packages... IPython : 8.18.1 ipykernel : 6.28.0 ipywidgets : not installed jupyter_client : 8.6.0 jupyter_core : 5.7.1 jupyter_server : 2.12.5 jupyterlab : 4.0.12 nbclient : 0.9.0 nbconvert : 7.16.0 nbformat : 5.9.2 notebook : 7.0.8 qtconsole : not installed traitlets : 5.14.1
@Timeroot Timeroot added bug status:Needs Triage Applied to issues that need triage labels Mar 1, 2024
@RRosio RRosio added regression and removed status:Needs Triage Applied to issues that need triage labels Mar 5, 2024
@itsmevichu
Copy link
Contributor

@Timeroot, there is already an option to open the JSON files with text editor.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants