Add centralized escaping of JSON strings

Enable correct escaping of " character thus removing the need to outlaw "s in comments
This commit is contained in:
Alexander Bock
2017-07-14 16:58:18 -04:00
parent 88b8789336
commit 6f524f4a67
6 changed files with 48 additions and 34 deletions

View File

@@ -603,8 +603,8 @@ std::string ScriptEngine::generateJson() const {
for (const LuaLibrary::Function& f : l.functions) {
json << "{";
json << "\"name\": \"" << f.name << "\", ";
json << "\"arguments\": \"" << f.argumentText << "\", ";
json << "\"help\": \"" << f.helpText << "\"";
json << "\"arguments\": \"" << escapedJson(f.argumentText) << "\", ";
json << "\"help\": \"" << escapedJson(f.helpText) << "\"";
json << "}";
if (&f != &l.functions.back() || !l.documentations.empty()) {
json << ",";
@@ -614,8 +614,8 @@ std::string ScriptEngine::generateJson() const {
for (const LuaLibrary::Documentation& doc : l.documentations) {
json << "{";
json << "\"name\": \"" << doc.name << "\", ";
json << "\"arguments\": \"" << doc.parameter<< "\", ";
json << "\"help\": \"" << doc.description<< "\"";
json << "\"arguments\": \"" << escapedJson(doc.parameter) << "\", ";
json << "\"help\": \"" << escapedJson(doc.description) << "\"";
json << "}";
if (&doc != &l.documentations.back()) {
json << ",";