| 89 | const auto * value = object.find(key); |
| 90 | if (value == nullptr || value->is_null()) { |
| 91 | return std::nullopt; |
| 92 | } |
| 93 | return value->as_number(); |
| 94 | } |
| 95 | |
| 96 | bool workflow_optional_bool( |
| 97 | const engine::io::json::Value & object, |
| 98 | const std::string & key, |
| 99 | bool fallback) { |
| 100 | const auto * value = object.find(key); |
| 101 | if (value == nullptr || value->is_null()) { |
| 102 | return fallback; |
| 103 | } |
| 104 | if (value->is_bool()) { |
| 105 | return value->as_bool(); |
| 106 | } |
| 107 | if (value->is_string()) { |
| 108 | const std::string & text = value->as_string(); |
| 109 | if (text == "true") { |
| 110 | return true; |
| 111 | } |
| 112 | if (text == "false") { |
| 113 | return false; |
| 114 | } |
| 115 | } |