1

I am wondering what's the difference between kTrueType and kFalseType in rapidjson. For example:

void writeTest(){
  rapidjson::Document document;
  rapidjson::Document::AllocatorType& allocator = 
  document.GetAllocator();
  rapidjson::Value root(rapidjson::kObjectType);
  rapidjson::Value test(rapidjson::kFalseType);
  test.SetBool(true);
  root.AddMember("test", test, allocator);
  rapidjson::StringBuffer buffer;
  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
  root.Accept(writer);
  std::cout << buffer.GetString() << std::endl;
 }

Even if I set the type to be kFalseType, I can still set the value of type to be true and vice versa. So what's the point of having two different types? Is this the right way to write a bool value to json? Thanks!

Rocking chief
  • 1,039
  • 3
  • 17
  • 31

0 Answers0