1 #include "ProfileAttribute.hpp"
2 #include "JsonFormatter.hpp"
5 gde::ProfileAttribute::toJson() const
7 std::string json = "{";
8 json += JsonFormatter::format("\"id\":", getId());
9 json += JsonFormatter::format(",\"name\":", getName());
10 json += JsonFormatter::format(",\"type\":", getType());
11 json += JsonFormatter::format(",\"profileId\":", getProfileId());
12 json += JsonFormatter::format(",\"mandatory\":", getMandatory());
18 gde::ProfileAttribute::fromJson(const std::string& json)
20 Poco::JSON::Object::Ptr object = JsonFormatter::parse(json);
22 int id = JsonFormatter::extract<int>(object, "id");
23 std::string name = JsonFormatter::extract<std::string>(object, "name");
24 std::string type = JsonFormatter::extract<std::string>(object, "type");
25 int profileId = JsonFormatter::extract<int>(object, "profileId");
26 bool mandatory = JsonFormatter::extract<bool>(object, "mandatory");
28 return gde::ProfileAttribute(id, name, type, profileId, mandatory);