Tyelab / bruker_control

Repository for code running the lab's multi-photon imaging experiments at the Bruker Ultima Investigator scope. Unites Arduino, Prairie View, and GenTL machine cameras in Python.
Mozilla Public License 2.0
8 stars 3 forks source link

json is Badly Formed in Output #155

Open jmdelahanty opened 1 year ago

jmdelahanty commented 1 year ago

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 commented 1 year ago

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.