Update JsonConvert.cs

This commit is contained in:
dogwatch
2014-09-16 21:37:39 +04:00
parent a32c34c78f
commit 040701ed68
+12 -2
View File
@@ -409,6 +409,11 @@ namespace Newtonsoft.Json
return ToString(value, '"');
}
public static string ToString(string value, StringEscapeHandling stringEscapeHandling)
{
return ToString(value, '"', stringEscapeHandling);
}
/// <summary>
/// Converts the <see cref="String"/> to its JSON string representation.
/// </summary>
@@ -416,11 +421,16 @@ namespace Newtonsoft.Json
/// <param name="delimiter">The string delimiter character.</param>
/// <returns>A JSON string representation of the <see cref="String"/>.</returns>
public static string ToString(string value, char delimiter)
{
return ToString(value, delimiter, true, StringEscapeHandling.Default);
}
public static string ToString(string value, char delimiter, StringEscapeHandling stringEscapeHandling)
{
if (delimiter != '"' && delimiter != '\'')
throw new ArgumentException("Delimiter must be a single or double quote.", "delimiter");
return JavaScriptUtils.ToEscapedJavaScriptString(value, delimiter, true);
return JavaScriptUtils.ToEscapedJavaScriptString(value, delimiter, true, stringEscapeHandling);
}
/// <summary>
@@ -1113,4 +1123,4 @@ namespace Newtonsoft.Json
}
#endif
}
}
}