Merge pull request #153 from oatpp/json_better_serializer

Json better serializer
This commit is contained in:
Leonid Stryzhevskyi 2019-11-17 05:49:55 +02:00 committed by GitHub
commit 02741a45cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -47,7 +47,7 @@ void Serializer::writeList(oatpp::data::stream::ConsistentOutputStream* stream,
while(curr != nullptr){
auto value = curr->getData();
if(value || config->includeNullFields) {
(first) ? first = false : stream->write(", ", 2);
(first) ? first = false : stream->write(",", 1);
writeValue(stream, curr->getData(), config);
}
curr = curr->getNext();
@ -64,10 +64,10 @@ void Serializer::writeFieldsMap(oatpp::data::stream::ConsistentOutputStream* str
while(curr != nullptr){
auto value = curr->getValue();
if(value || config->includeNullFields) {
(first) ? first = false : stream->write(", ", 2);
(first) ? first = false : stream->write(",", 1);
auto key = curr->getKey();
writeString(stream, key->getData(), key->getSize());
stream->write(": ", 2);
stream->write(":", 1);
writeValue(stream, curr->getValue(), config);
}
curr = curr->getNext();
@ -88,9 +88,9 @@ void Serializer::writeObject(oatpp::data::stream::ConsistentOutputStream* stream
auto value = field->get(object);
if(value || config->includeNullFields) {
(first) ? first = false : stream->write(", ", 2);
(first) ? first = false : stream->write(",", 1);
writeString(stream, field->name);
stream->write(": ", 2);
stream->write(":", 1);
writeValue(stream, value, config);
}

View File

@ -104,14 +104,15 @@ void UnicodeTest::onRun(){
}
// 6 byte test
for(v_int32 c = 67108864; c < 2147483647; c ++){
v_int32 size = oatpp::encoding::Unicode::decodeUtf8Char(c, buff);
for (v_int64 c = 67108864; c < 2147483647; c = c + 100) {
v_int32 size = oatpp::encoding::Unicode::decodeUtf8Char((v_int32) c, buff);
OATPP_ASSERT(size == 6);
v_int32 code = oatpp::encoding::Unicode::encodeUtf8Char(buff, cnt);
OATPP_ASSERT(cnt == 6);
OATPP_ASSERT(code == c);
}
// */
p_char8 sequence = (p_char8)"𐐷";