This micropython-lib json library is quite old, I'm guessing it was written against the ffi re module (unix only version).
Are there features in this json that the built-in one is missing?
The json lib module seems to have an issue. That was not observed in 2018.
To reproduce the error take:
r = requests.get('https://aa.usno.navy.mil/api/rstt/oneday?date=2023-11-21 &coords=48.441832,9.890139 &tz=2').json()
Generated error message:
File "requests/init.py", line 33, in json
ValueError: syntax error in JSON
/ # mpy
MicroPython v1.20.0-348-g24a6e951e-dirty on 2023-08-13; linux [] version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import mip
>>> mip.install('json')
Installing json (latest) from https://micropython.org/pi/v2 to /usr/micropython/lib
Copying: /usr/micropython/lib/json/__init__.mpy
Copying: /usr/micropython/lib/json/encoder.mpy
Copying: /usr/micropython/lib/json/scanner.mpy
Copying: /usr/micropython/lib/json/tool.mpy
Copying: /usr/micropython/lib/json/decoder.mpy
Done
>>> import json
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "json/__init__.py", line 114, in <module>
File "json/decoder.py", line 6, in <module>
File "json/scanner.py", line 13, in <module>
AttributeError: 'module' object has no attribute 'VERBOSE
This micropython-lib json library is quite old, I'm guessing it was written against the ffi re module (unix only version).
Are there features in this json that the built-in one is missing?
This micropython-lib json library is quite old, I'm guessing it was written against the ffi re module (unix only version).
Are there features in this json that the built-in one is missing?
the json library depends on re library, and need constants below, which is not in embedded re module implementation:
re.VERBOSE
re.MULTILINE
re.DOTALL
I meant are you trying to use the mip installed json to do something that doesn't work on the builtin import json?
No, I just do a test.
I have switched to embedded json.
This returns status_code==400 on my ESP32C3 , here is REPL :
The request works fine on my Linux box - using ipython- and returns a good
jsonstring. Thetextis not JSON. Maybe the difficulty is inrequestsmodule?On the ESP32C3 micropython:
On my linux box:
If I remove the space between date and
&coordsand remove the space abetween coordinates and&tzit works:It works ... sometimes, means it is not stable.
I often get this error:
...
File "requests/init.py", line 180, in get
File "requests/init.py", line 76, in request
OSError: -202
In order to be able to debug the issue, you need to provide examples of valid JSON that the library does not parse.