Actions
Improvements #12675
open[Dbo::JsonSerializer] Support built-in types
Start date:
05/17/2024
Due date:
% Done:
0%
Estimated time:
Description
Wt::Dbo guide says:
There is also support for built-in Wt types such as WDate, WDateTime, WTime and WString which can be enabled by including <Wt/Dbo/WtSqlTraits.h>.
So I wonder why JsonSerializer does not support them
https://redmine.emweb.be/boards/2/topics/14991
Updated by Andrey Alekseev 4 months ago
I found out that type support may be extended for my project just like this
namespace Wt { namespace Dbo {
template<typename T>
typename std::enable_if< !std::is_enum<T>::value, void>::type
JsonSerializer::act(FieldRef<T> field){
writeFieldName(field.name());
WString v = field.value().toString();
JsonSerializer::act( FieldRef<WString>(v, field.name(), field.size(), field.flags()));
}
template<>
void JsonSerializer::act(FieldRef<WString> field){
std::string v = field.value().toUTF8();
JsonSerializer::act( FieldRef<std::string>(v, field.name(), field.size(), field.flags()));
}
}}
thanks to the template declered in the header file
Updated by Matthias Van Ceulebroeck 2 months ago
- Assignee set to Romain Mardulyn
- Target version set to 4.11.1
Updated by Romain Mardulyn about 1 month ago
- Status changed from New to InProgress
Updated by Romain Mardulyn about 1 month ago
- Status changed from InProgress to Review
- Assignee deleted (
Romain Mardulyn)
Actions