mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-19 09:53:08 +02:00
Hooks
- Cleaned up logic for crude JSON detection.
This commit is contained in:
parent
8fb3161a02
commit
e00704a375
1 changed files with 4 additions and 29 deletions
|
@ -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 <std::string>::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] == '}';
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue