Created
March 11, 2022 08:04
-
-
Save ivanstojic/e072deea3ba411374ed66ead99dbbef8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "rapidjson/document.h" | |
#include "rapidjson/writer.h" | |
#include "rapidjson/stringbuffer.h" | |
#include <iostream> | |
using namespace rapidjson; | |
int main() { | |
const char* json = "{\"thing\":-1.1030161663305387}"; | |
Document d; | |
d.Parse(json); | |
StringBuffer roundtripBuffer; | |
Writer<StringBuffer> beforeWriter(roundtripBuffer); | |
d.Accept(beforeWriter); | |
Value& s = d["thing"]; | |
double thingVal = -1.1030161663305387; | |
s.SetDouble(thingVal); | |
StringBuffer nativeSetBuffer; | |
Writer<StringBuffer> afterWriter(nativeSetBuffer); | |
d.Accept(afterWriter); | |
std::cout << json << std::endl; | |
std::cout << roundtripBuffer.GetString() << std::endl; | |
std::cout << nativeSetBuffer.GetString() << std::endl; | |
return 0; | |
} |
Author
ivanstojic
commented
Mar 11, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment