Update JsonConvert.cs
This commit is contained in:
@@ -409,6 +409,11 @@ namespace Newtonsoft.Json
|
|||||||
return ToString(value, '"');
|
return ToString(value, '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ToString(string value, StringEscapeHandling stringEscapeHandling)
|
||||||
|
{
|
||||||
|
return ToString(value, '"', stringEscapeHandling);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts the <see cref="String"/> to its JSON string representation.
|
/// Converts the <see cref="String"/> to its JSON string representation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -416,11 +421,16 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="delimiter">The string delimiter character.</param>
|
/// <param name="delimiter">The string delimiter character.</param>
|
||||||
/// <returns>A JSON string representation of the <see cref="String"/>.</returns>
|
/// <returns>A JSON string representation of the <see cref="String"/>.</returns>
|
||||||
public static string ToString(string value, char delimiter)
|
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 != '\'')
|
if (delimiter != '"' && delimiter != '\'')
|
||||||
throw new ArgumentException("Delimiter must be a single or double quote.", "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>
|
/// <summary>
|
||||||
@@ -1113,4 +1123,4 @@ namespace Newtonsoft.Json
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user