Commit 3d4890c54aa956f25d30d1f23f55d0ad613cf3b8
1 parent
fd5c3146
Cleanup and improvement of json usage
Showing
2 changed files
with
2 additions
and
3 deletions
hueplusplus/Hue.cpp
| ... | ... | @@ -249,7 +249,7 @@ const HueLight& Hue::getLight(int id) |
| 249 | 249 | return lights.find(id)->second; |
| 250 | 250 | } |
| 251 | 251 | refreshState(); |
| 252 | - if (state["lights"][std::to_string(id)] == Json::nullValue) | |
| 252 | + if (!state["lights"].isMember(std::to_string(id))) | |
| 253 | 253 | { |
| 254 | 254 | std::cout << "Error in Hue getLight(): light with id " << id << " is not valid\n"; |
| 255 | 255 | throw(std::runtime_error("Error in Hue getLight(): light id is not valid")); | ... | ... |
hueplusplus/HueLight.cpp
| ... | ... | @@ -19,7 +19,6 @@ |
| 19 | 19 | |
| 20 | 20 | #include "include/HueLight.h" |
| 21 | 21 | |
| 22 | - | |
| 23 | 22 | #include "include/HttpHandler.h" |
| 24 | 23 | #include "include/json/json.h" |
| 25 | 24 | |
| ... | ... | @@ -220,4 +219,4 @@ void HueLight::refreshState() |
| 220 | 219 | throw(std::runtime_error("Error while parsing JSON in function refreshState() of HueLight")); |
| 221 | 220 | } |
| 222 | 221 | std::cout << "\tRefresh state took: " << std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count() << "ms" << std::endl; |
| 223 | 222 | -} |
| 223 | +} | |
| 224 | 224 | \ No newline at end of file | ... | ... |