From 6e252aa0d5d19237f352eeec66589fdd0fdcb190 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 1 Feb 2014 13:23:12 +0000 Subject: [PATCH] - metadata will be printed before node value, fixes #1678 --- lib/JsonDetail.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/JsonDetail.cpp b/lib/JsonDetail.cpp index 0baec2745..c788c4cd4 100644 --- a/lib/JsonDetail.cpp +++ b/lib/JsonDetail.cpp @@ -42,6 +42,8 @@ void JsonWriter::writeContainer(Iterator begin, Iterator end) void JsonWriter::writeEntry(JsonMap::const_iterator entry) { + if (!entry->second.meta.empty()) + out << prefix << " // " << entry->second.meta << "\n"; out << prefix; writeString(entry->first); out << " : "; @@ -50,6 +52,8 @@ void JsonWriter::writeEntry(JsonMap::const_iterator entry) void JsonWriter::writeEntry(JsonVector::const_iterator entry) { + if (!entry->meta.empty()) + out << prefix << " // " << entry->meta << "\n"; out << prefix; writeNode(*entry); } @@ -104,8 +108,6 @@ void JsonWriter::writeNode(const JsonNode &node) writeContainer(node.Struct().begin(), node.Struct().end()); out << prefix << "}"; } - if (!node.meta.empty()) // write metainf as comment - out << " //" << node.meta; } JsonWriter::JsonWriter(std::ostream &output, const JsonNode &node): @@ -305,7 +307,7 @@ bool JsonParser::extractLiteral(const std::string &literal) if (literal.compare(0, literal.size(), &input[pos], literal.size()) != 0) { while (pos < input.size() && ((input[pos]>'a' && input[pos]<'z') - || (input[pos]>'A' && input[pos]<'Z'))) + || (input[pos]>'A' && input[pos]<'Z'))) pos++; return error("Unknown literal found", true); } @@ -496,7 +498,7 @@ bool JsonParser::error(const std::string &message, bool warning) std::string type(warning?" warning: ":" error: "); stream << "At line " << lineCount << ", position "<