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
Allow unsetting (deleting) parameters #145
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,14 +21,20 @@ void to_json(nlohmann::json& j, const Parameter& p) { | |
} else if (paramType == ParameterType::PARAMETER_STRING_ARRAY) { | ||
j["value"] = p.getValue<std::vector<std::string>>(); | ||
} else if (paramType == ParameterType::PARAMETER_NOT_SET) { | ||
throw std::runtime_error("Unintialized parameter"); | ||
// empty value. | ||
} | ||
|
||
j["name"] = p.getName(); | ||
} | ||
|
||
void from_json(const nlohmann::json& j, Parameter& p) { | ||
const auto name = j["name"].get<std::string>(); | ||
|
||
if (j.find("value") == j.end()) { | ||
p = Parameter(name); // Value is not set (undefined). | ||
return; | ||
} | ||
Comment on lines
+33
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be more explicit if the value was set to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand the comment here, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was referring to foxglove/ws-protocol#354 (comment), where we chose to use |
||
|
||
const auto value = j["value"]; | ||
const auto jsonType = j["value"].type(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec currently does not declare what parameter message to expect when requesting a non-existing / deleted parameter. Should it be
or
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second example is not valid JSON. There is no
undefined
literal in https://www.rfc-editor.org/rfc/rfc8259There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adapted my first comment by removing the
value
fieldThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the first is better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, that's also how it is currently implemented