Project

General

Profile

Actions

Improvements #12675

closed

[Dbo::JsonSerializer] Support built-in types

Added by Andrey Alekseev 7 months ago. Updated about 2 months ago.

Status:
Closed
Priority:
Normal
Target version:
Start date:
05/17/2024
Due date:
% Done:

100%

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

Actions #1

Updated by Andrey Alekseev 7 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

Actions #2

Updated by Matthias Van Ceulebroeck 6 months ago

  • Assignee set to Romain Mardulyn
  • Target version set to 4.11.1
Actions #3

Updated by Romain Mardulyn 5 months ago

  • Status changed from New to InProgress
Actions #4

Updated by Romain Mardulyn 5 months ago

  • Status changed from InProgress to Review
  • Assignee deleted (Romain Mardulyn)
Actions #5

Updated by Matthias Van Ceulebroeck 2 months ago

  • Assignee set to Matthias Van Ceulebroeck
Actions #6

Updated by Matthias Van Ceulebroeck about 2 months ago

  • Status changed from Review to Implemented @Emweb
  • Assignee changed from Matthias Van Ceulebroeck to Romain Mardulyn
  • % Done changed from 0 to 100
Actions #7

Updated by Matthias Van Ceulebroeck about 2 months ago

  • Status changed from Implemented @Emweb to Implemented @Test
Actions #8

Updated by Matthias Van Ceulebroeck about 2 months ago

  • Status changed from Implemented @Test to Closed
Actions

Also available in: Atom PDF