1#include <xrpl/json/Writer.h> 
    3#include <doctest/doctest.h> 
    4#include <google/protobuf/stubs/port.h> 
   47    CHECK(output.empty());
 
   48    checkOutputAndReset(
"");
 
   53    CHECK(output.empty());
 
   55    checkOutputAndReset(
"0");
 
   61    checkOutputAndReset(
"true");
 
   63    writer->output(
false);
 
   64    checkOutputAndReset(
"false");
 
   67    checkOutputAndReset(
"23");
 
   70    checkOutputAndReset(
"23.0");
 
   73    checkOutputAndReset(
"23.5");
 
   75    writer->output(
"a string");
 
   76    checkOutputAndReset(R
"("a string")"); 
   78    writer->output(nullptr);
 
   79    checkOutputAndReset(
"null");
 
   86    checkOutputAndReset(
"[]");
 
   90    checkOutputAndReset(
"{}");
 
   96    checkOutputAndReset(R
"("\\")"); 
   99    checkOutputAndReset(R
"("\"")"); 
  101    writer->output("\\\"");
 
  102    checkOutputAndReset(R
"("\\\"")"); 
  104    writer->output("this contains a \\ in the middle of it.");
 
  105    checkOutputAndReset(R
"("this contains a \\ in the middle of it.")"); 
  107    writer->output("\b\f\n\r\t");
 
  108    checkOutputAndReset(R
"("\b\f\n\r\t")"); 
  116    checkOutputAndReset(
"[12]");
 
  123    writer->append(
true);
 
  124    writer->append(
"hello");
 
  126    checkOutputAndReset(R
"([12,true,"hello"])"); 
  135    checkOutputAndReset(
"[[]]");
 
  141    writer->set(
"hello", 
"world");
 
  143    checkOutputAndReset(R
"({"hello":"world"})"); 
  149    writer->set(
"hello", 
"world");
 
  151    writer->append(
true);
 
  155    writer->set(
"goodbye", 
"cruel world.");
 
  157    writer->append(23.5);
 
  160        R
"({"hello":"world","array":[true,12,[{"goodbye":"cruel world.","subarray":[23.5]}]]})"); 
  168    writer->set(
"hello", value);
 
  170    checkOutputAndReset(R
"({"hello":{"foo":23}})"); 
JSON (JavaScript Object Notation).
 
Output stringOutput(std::string &s)
 
@ objectValue
object value (collection of name/value pairs).
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
TEST_SUITE_BEGIN("json_value")
 
void expectOutput(std::string const &expected) const
 
void checkOutputAndReset(std::string const &expected)
 
std::unique_ptr< Writer > writer