From e00704a3754bc872f7b5709d18e686e08d963b34 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 14 Feb 2015 17:31:37 -0500 Subject: [PATCH] Hooks - Cleaned up logic for crude JSON detection. --- src/Hooks.cpp | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/src/Hooks.cpp b/src/Hooks.cpp index 7d9d772d7..cf66c3063 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -333,7 +333,7 @@ void Hooks::onModify (const Task& before, Task& after) if (status == 0) { - // Propagate forward to the next script. + // Propagate accepted changes forward to the next script. input[1] = outputJSON[0]; std::vector ::iterator message; @@ -397,34 +397,9 @@ void Hooks::separateOutput ( //////////////////////////////////////////////////////////////////////////////// bool Hooks::isJSON (const std::string& input) const { - if (input.length () < 3 || - input[0] != '{' || - input[input.length () - 1] != '}') - return false; - -/* - I think this is not necessary, and a simple JSON test is all that is needed. - - try - { - json::value* root = json::parse (input); - if (root->type () != json::j_object) - return false; - - if (((json::object*)root)->_data.find ("description") == ((json::object*)root)->_data.end ()) - return false; - - if (((json::object*)root)->_data.find ("uuid") == ((json::object*)root)->_data.end ()) - return false; - } - - catch (...) - { - return false; - } -*/ - - return true; + return input.length () > 2 && + input[0] == '{' && + input[input.length () - 1] == '}'; } ////////////////////////////////////////////////////////////////////////////////