Repository: mesos Updated Branches: refs/heads/master 822738826 -> 304ad5e14
Simplified label JSON modeling with JSON::Protobuf. JSON fields doesn't need to be set explicitly, so label modeling can be simplified with JSON::Protobuf. Review: https://reviews.apache.org/r/28287 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/304ad5e1 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/304ad5e1 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/304ad5e1 Branch: refs/heads/master Commit: 304ad5e14a6210ec845f7cc5bf97b2fac9c79025 Parents: 8227388 Author: Niklas Nielsen <[email protected]> Authored: Thu Nov 20 11:35:08 2014 -0800 Committer: Niklas Q. Nielsen <[email protected]> Committed: Thu Nov 20 11:35:08 2014 -0800 ---------------------------------------------------------------------- src/common/http.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/304ad5e1/src/common/http.cpp ---------------------------------------------------------------------- diff --git a/src/common/http.cpp b/src/common/http.cpp index b21e18d..422fa68 100644 --- a/src/common/http.cpp +++ b/src/common/http.cpp @@ -21,6 +21,7 @@ #include <mesos/resources.hpp> #include <stout/foreach.hpp> +#include <stout/protobuf.hpp> #include <stout/stringify.hpp> #include "common/attributes.hpp" @@ -132,10 +133,7 @@ JSON::Object model(const Task& task) JSON::Array labels; foreach (const Label& label, task.labels()) { - JSON::Object labelObject; - labelObject.values["key"] = label.key(); - labelObject.values["value"] = label.has_value() ? label.value() : ""; - labels.values.push_back(labelObject); + labels.values.push_back(JSON::Protobuf(label)); } object.values["labels"] = labels; @@ -173,10 +171,7 @@ JSON::Object model( JSON::Array labels; foreach (const Label& label, task.labels()) { - JSON::Object labelObject; - labelObject.values["key"] = label.key(); - labelObject.values["value"] = label.has_value() ? label.value() : ""; - labels.values.push_back(labelObject); + labels.values.push_back(JSON::Protobuf(label)); } object.values["labels"] = labels;
