1010#include " position.hh"
1111#include " JsonVisitor.h"
1212
13- #include < assert.h >
13+ #include < cassert >
1414#include < iterator>
1515
1616namespace facebook {
@@ -28,7 +28,10 @@ JsonVisitor::NodeFieldPrinter::NodeFieldPrinter(
2828 if (!visitor_.printed_ .empty ()) {
2929 nextChild_ = visitor_.printed_ .back ().begin ();
3030 }
31- out_ << " {\" kind\" :\" " << nodeKind << " \" ,\" loc\" :" ;
31+ // NOTE: If you're an Emacs user and this file's use of C++11 raw
32+ // strings doesn't highlight correctly in c++-mode, try upgrading to
33+ // Emacs 26 if you can.
34+ out_ << R"( {"kind":")" << nodeKind << R"( ","loc":)" ;
3235 printLocation (out_, node.getLocation ());
3336}
3437
@@ -52,21 +55,21 @@ void JsonVisitor::NodeFieldPrinter::printSingularPrimitiveField(
5255 const char *fieldName,
5356 const char *value) {
5457 printFieldSeparator ();
55- out_ << ' "' << fieldName << " \" : " ;
58+ out_ << ' "' << fieldName << R"( ": ) " ;
5659 out_ << ' "' << value << ' "' ;
5760}
5861
5962void JsonVisitor::NodeFieldPrinter::printSingularBooleanField (
6063 const char *fieldName,
6164 bool value) {
6265 printFieldSeparator ();
63- out_ << ' "' << fieldName << " \" : " ;
66+ out_ << ' "' << fieldName << R"( ": ) " ;
6467 out_ << (value ? " true" : " false" );
6568}
6669
6770void JsonVisitor::NodeFieldPrinter::printSingularObjectField (const char *fieldName) {
6871 printFieldSeparator ();
69- out_ << ' "' << fieldName << " \" : " ;
72+ out_ << ' "' << fieldName << R"( ": ) " ;
7073 assert (!visitor_.printed_ .empty ());
7174 out_ << *nextChild_++;
7275}
@@ -75,7 +78,7 @@ void JsonVisitor::NodeFieldPrinter::printNullableSingularObjectField(
7578 const char *fieldName,
7679 const void *value) {
7780 printFieldSeparator ();
78- out_ << ' "' << fieldName << " \" : " ;
81+ out_ << ' "' << fieldName << R"( ": ) " ;
7982 if (value != nullptr ) {
8083 assert (!visitor_.printed_ .empty ());
8184 out_ << *nextChild_++;
@@ -89,10 +92,10 @@ void JsonVisitor::NodeFieldPrinter::printLocation(
8992 std::ostringstream &out,
9093 const yy::location &location)
9194{
92- out << " { \ " start\ " : {\ " line\ " : " << location.begin .line
93- << " , \ " column\" : " << location.begin .column
94- << " }, \ " end\ " : {\ " line\" : " << location.end .line
95- << " , \ " column\" : " << location.end .column
95+ out << R"( { "start": {"line": ) " << location.begin .line
96+ << R"( , "column": ) " << location.begin .column
97+ << R"( }, "end": {"line": ) " << location.end .line
98+ << R"( , "column": ) " << location.end .column
9699 << " }}" ;
97100}
98101
@@ -131,7 +134,7 @@ std::string JsonVisitor::getResult() const {
131134
132135#include " JsonVisitor.cpp.inc"
133136
134- }
135- }
136- }
137- }
137+ } // namespace visitor
138+ } // namespace ast
139+ } // namespace graphql
140+ } // namespace facebook
0 commit comments