-
Notifications
You must be signed in to change notification settings - Fork 47
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 keys and string values need to be wrapped in double quotes #199
Comments
Just had a quick check and the few I looked at look are quoted correctly. Please can you give the specific endpoint that has an error? |
The Function create_rapi_json()
I have changed the function: create_rapi_json() {
url = e_url;
data = "";
url += String(emoncms_node) + "&json={";
data += "\\"amp\\":" + String(amp) + ",";
if (volt > 0) {
data += "volt:" + String(volt) + ",";
}
data += "\"wh\":" + String(watthour_total) + ",";
data += "\"temp1\":" + String(temp1) + ",";
data += "\"temp2\":" + String(temp2) + ",";
data += "\"temp3\":" + String(temp3) + ",";
data += "\"pilot\":" + String(pilot) + ",";
data += "\"state\":" + String(state) + ",";
data += "\"freeram\":" + String(ESP.getFreeHeap()) + ",";
data += "\"divertmode\":" + String(divertmode);
url += data;
if (emoncms_server == "data.openevse.com/emoncms") {
// data.openevse uses device module
url += "}&devicekey=" + emoncms_apikey;
} else {
// emoncms.org does not use device module
url += "}&apikey=" + emoncms_apikey;
}
//DEBUG.print(emoncms_server.c_str() + String(url));
} Now the request is:
I checked the change in my existing account in data.openevse.com/emoncms and everything works as expected. |
Ah that JSON ;-) I think that should be ok, may cause some issues with legacy setups but the current EmonCMS handes this OK, @glynhudson what do you think? |
I also looked at the mqtt_publish() function, I think it will work fine there too. |
Resolve #199. Add escaped double-quote to the json string
Great, thanks. I've just tested and emoncms handles it just fine. PR has been merged 👍 |
Resolve OpenEVSE#199. Add escaped double-quote to the json string
Services written in different languages (eg golang) are very strict on Json format and will throw error if there are no double quotes around the keys
The text was updated successfully, but these errors were encountered: