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 is Badly Formed in Output #155

Open
jmdelahanty opened this issue Apr 14, 2023 · 1 comment
Open

json is Badly Formed in Output #155

jmdelahanty opened this issue Apr 14, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@jmdelahanty
Copy link
Contributor

It appears that loading the configuration files is broken. Something in my json dump is incorrect. It's likely this has been happening the entire time the library has been in use. Embarrassing.

When you try and load it in Python, you get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jdelahanty/miniconda3/envs/sleap/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/home/jdelahanty/miniconda3/envs/sleap/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/jdelahanty/miniconda3/envs/sleap/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

MATLAB encounters a similar error, which is currently solved by a workaround Hao wrote. I found out about this workaround a couple days ago. When I was first testing things I didn't encounter this problem. Checking with online json validators appears to register the file as a valid json file/correctly written json.

@jmdelahanty jmdelahanty added the bug Something isn't working label Apr 14, 2023
@jmdelahanty jmdelahanty self-assigned this Apr 14, 2023
@jmdelahanty
Copy link
Contributor Author

It turns out if you do:

with open("/path/to/filename/", "r") as f:
     x = json.load(f)

It works. Doing it like:

x = json.load(f)

Does not.

Not sure yet why MATLAB isn't doing it right. Once that's solved I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant