Extend data serialization with JSON
This commit is contained in:
parent
772e4f4ca4
commit
765d887943
|
@ -94,6 +94,9 @@ std::string PropertyPythonObject::toString() const
|
|||
else if (this->object.hasAttr("__dict__")) {
|
||||
dump = this->object.getAttr("__dict__");
|
||||
}
|
||||
else {
|
||||
dump = this->object;
|
||||
}
|
||||
|
||||
Py::Tuple args(1);
|
||||
args.setItem(0, dump);
|
||||
|
@ -125,9 +128,12 @@ void PropertyPythonObject::fromString(const std::string& repr)
|
|||
Py::Callable state(this->object.getAttr("__setstate__"));
|
||||
state.apply(args);
|
||||
}
|
||||
else {
|
||||
else if (this->object.hasAttr("__dict__")) {
|
||||
this->object.setAttr("__dict__", res);
|
||||
}
|
||||
else {
|
||||
this->object = res;
|
||||
}
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
|
@ -269,6 +275,9 @@ void PropertyPythonObject::Save (Base::Writer &writer) const
|
|||
<< " class=\"" << (std::string)name << "\"";
|
||||
}
|
||||
}
|
||||
else {
|
||||
writer.Stream() << " json=\"yes\"";
|
||||
}
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
|
@ -333,6 +342,9 @@ void PropertyPythonObject::Restore(Base::XMLReader &reader)
|
|||
load_pickle = true;
|
||||
buffer = std::string(what[2].second, end);
|
||||
}
|
||||
else if (reader.hasAttribute("json")) {
|
||||
load_json = true;
|
||||
}
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
|
|
Loading…
Reference in New Issue
Block a user