rapidjson icon indicating copy to clipboard operation
rapidjson copied to clipboard

Support line ending options

Open SinghRajenM opened this issue 2 years ago • 4 comments

SinghRajenM avatar Oct 09 '22 16:10 SinghRajenM

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

tencent-adm avatar Oct 09 '22 16:10 tencent-adm

I think this can be done in output stream instead. Also, standard file i/o stream should already have conversion.

miloyip avatar Oct 10 '22 07:10 miloyip

I think this can be done in output stream instead. Also, standard file i/o stream should already have conversion.

I am not pretty much sure about it.

But we are using StringBuffer to get prettier string. Something like below -

    rj::StringBuffer                                                                                      sb;
    rj::PrettyWriter<rj::StringBuffer, rj::UTF8<>, rj::UTF8<>, rj::CrtAllocator, rj::kWriteNanAndInfFlag> handler(sb);
    handler.SetLineEnding(le);
    handler.SetFormatOptions(lf);
    handler.SetIndent(indentChar, indentLen);
    
    rj::Reader       reader;
    rj::StringStream ss(jsonText.c_str());
    success = reader.Parse<someflags>(ss, handler) && sb.GetString();

Here, we are expecting that sb.GetString should provide pretty json with desired line ending option.

SinghRajenM avatar Oct 10 '22 15:10 SinghRajenM

@miloyip Is there anything needed from my end to get this accepted and merged?

SinghRajenM avatar Nov 27 '22 04:11 SinghRajenM