|
|
@@ -589,67 +589,6 @@ namespace SimpleJson |
|
|
|
return SerializeObject(json, CurrentJsonSerializerStrategy);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string EscapeToJavascriptString(string jsonString)
|
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(jsonString))
|
|
|
|
{
|
|
|
|
return jsonString;
|
|
|
|
}
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
char c;
|
|
|
|
|
|
|
|
for (int i = 0; i < jsonString.Length; )
|
|
|
|
{
|
|
|
|
c = jsonString[i++];
|
|
|
|
|
|
|
|
if (c == '\\')
|
|
|
|
{
|
|
|
|
int remainingLength = jsonString.Length - i;
|
|
|
|
if (remainingLength >= 2)
|
|
|
|
{
|
|
|
|
char lookahead = jsonString[i];
|
|
|
|
if (lookahead == '\\')
|
|
|
|
{
|
|
|
|
sb.Append('\\');
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
else if (lookahead == '"')
|
|
|
|
{
|
|
|
|
sb.Append("\"");
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
else if (lookahead == 't')
|
|
|
|
{
|
|
|
|
sb.Append('\t');
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
else if (lookahead == 'b')
|
|
|
|
{
|
|
|
|
sb.Append('\b');
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
else if (lookahead == 'n')
|
|
|
|
{
|
|
|
|
sb.Append('\n');
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
else if (lookahead == 'r')
|
|
|
|
{
|
|
|
|
sb.Append('\r');
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sb.Append(c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected static IDictionary<string, object> ParseObject(char[] json, ref int index, ref bool success)
|
|
|
|
{
|
|
|
|
IDictionary<string, object> table = new JsonObject();
|
|
|
|