Fixed the issue when reading or writing escaped JSON strings from and to LS.

This commit is contained in:
ruri
2019-04-20 14:29:04 +02:00
parent f88d80f27f
commit 29180b0165
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -57,7 +57,7 @@ namespace RuriLib.LS
input = input.Substring(token.Length).Trim();
if (type == TokenType.Literal)
token = token.Substring(1, token.Length - 2).Replace("\\\"", "\"");
token = token.Substring(1, token.Length - 2).Replace("\\\\", "\\").Replace("\\\"", "\"");
}
else
{
@@ -219,7 +219,8 @@ namespace RuriLib.LS
return "^[^ ]*";
case TokenType.Literal:
return "\\\"(\\\\.|[^\\\"])*\\\"";
//return "\\\"(\\\\.|[^\\\"])*\\\"";
return "\"(\\\\.|[^\\\"])*\"";
case TokenType.Arrow:
return "^->";
+1 -1
View File
@@ -67,7 +67,7 @@ namespace RuriLib.LS
public BlockWriter Literal(string literal, string property = "")
{
if (property != "" && CheckDefault(literal, property)) return this;
Write($"\"{literal.Replace("\"", "\\\"")}\" ");
Write($"\"{literal.Replace("\\", "\\\\").Replace("\"", "\\\"")}\" ");
return this;
}