gmag11 / EnigmaIOT

Secure sensor and gateway platform based on ESP8266 and ESP32
https://gmag11.github.io/EnigmaIOT
MIT License
240 stars 46 forks source link

API doesn't send correct json #20

Closed G2G2G2G closed 3 years ago

G2G2G2G commented 3 years ago

All of the web API sends single quotes instead of double quotes

https://github.com/gmag11/EnigmaIOT/blob/master/docs/api.md

gmag11 commented 3 years ago

Yes, this is intended to simplify string management in C++ code. Single quotes are valid in JSON, aren't they? At least Insomnia shows correct decoded JSON data. image

G2G2G2G commented 3 years ago

Yes I saw that in your code, unfortunately no JSON spec is double quotes only, some references here: https://stackoverflow.com/questions/14355655/jquery-parsejson-single-quote-vs-double-quote

I can edit it, if you don't have time, but I would just switch all of the ' to \" instead. It is a lot uglier, but that is the JSON spec. browsers do not parse it correctly and just throw errors when your current json. You can navigate to the gateway api in any browser and see the errors if you want, only way to view the data is via the 'raw' setting where it doesn't parse for you. No idea what insomnia is

gmag11 commented 3 years ago

Thank you. I'll change this in next release.

gmag11 commented 3 years ago

It should be solved in a5b2a76. Thanks again