Merge with master

This commit is contained in:
lganzzzo 2021-10-16 02:00:50 +03:00
commit cc6c54f3a9
4 changed files with 12 additions and 3 deletions

View File

@ -19,8 +19,7 @@
**News**
- Hey, meet the new oatpp version `1.2.5`! See the [changelog](changelog/1.2.5.md) for details.
- Check out the new oatpp ORM - read more [here](https://oatpp.io/docs/components/orm/).
- Hey, the new oatpp version `1.3.0` will soon be merged to master! Follow the [changelog](https://github.com/oatpp/oatpp/blob/v1.3.0/changelog/1.3.0.md) for details, and prepare for migration. *[Follow PR](https://github.com/oatpp/oatpp/pull/453)*.
---

View File

@ -27,6 +27,7 @@
#include <functional>
#include "oatpp/core/base/Environment.hpp"
#include "oatpp/core/macro/basic.hpp"
namespace oatpp { namespace test {
@ -92,8 +93,10 @@ public:
#define OATPP_RUN_TEST_0(TEST) \
oatpp::test::UnitTest::runTest<TEST>(1)
#define OATPP_RUN_TEST_1(TEST, N) \
oatpp::test::UnitTest::runTest<TEST>(N)
/**
* Convenience macro to run test. <br>
* Usage Example:<br>

View File

@ -155,11 +155,12 @@ void Serializer::serializeObject(Serializer* serializer,
);
auto fields = dispatcher->getProperties()->getList();
auto object = static_cast<oatpp::BaseObject*>(polymorph.get());
auto config = serializer->m_config;
for (auto const& field : fields) {
auto value = field->get(object);
if(value || serializer->m_config->includeNullFields) {
if (value || config->includeNullFields || (field->info.required && config->alwaysIncludeRequired)) {
(first) ? first = false : stream->writeSimple(",", 1);
serializeString(stream, field->name, std::strlen(field->name), serializer->m_config->escapeFlags);
stream->writeSimple(":", 1);

View File

@ -66,9 +66,15 @@ public:
/**
* Include fields with value == nullptr into serialized json.
* Field will still be included when field-info `required` is set to true and &id:alwaysIncludeRequired is set to true.
*/
bool includeNullFields = true;
/**
* Always include required fields (set in in DTO_FIELD_INFO) even if they are `value == nullptr`
*/
bool alwaysIncludeRequired = false;
/**
* If `true` - insert string `"<unknown-type>"` in json field value in case unknown field found.
* Fail if `false`.