]> SALOME platform Git repositories - modules/gde.git/blob - projects/GDE_API_CPP/api/src/ProfileAttribute.cpp
Salome HOME
FileService
[modules/gde.git] / projects / GDE_API_CPP / api / src / ProfileAttribute.cpp
1 #include "ProfileAttribute.hpp"
2 #include "JsonFormatter.hpp"
3
4 const std::string
5 gde::ProfileAttribute::toJson() const
6 {
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());
13   json += "}";
14   return json;
15 }
16
17 gde::ProfileAttribute
18 gde::ProfileAttribute::fromJson(const std::string& json)
19 {
20   Poco::JSON::Object::Ptr object = JsonFormatter::parse(json);
21
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");
27
28   return gde::ProfileAttribute(id, name, type, profileId, mandatory);
29 }