diff options
Diffstat (limited to 'Src/Newtonsoft.Json/JsonReader.cs')
-rw-r--r-- | Src/Newtonsoft.Json/JsonReader.cs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Src/Newtonsoft.Json/JsonReader.cs b/Src/Newtonsoft.Json/JsonReader.cs index b22fba3..8478c8c 100644 --- a/Src/Newtonsoft.Json/JsonReader.cs +++ b/Src/Newtonsoft.Json/JsonReader.cs @@ -103,6 +103,7 @@ namespace Newtonsoft.Json internal State _currentState;
private JTokenType _currentTypeContext;
private bool _serializerInArray;
+ private CultureInfo _culture;
internal void SetSerializeInArray(bool serializerInArray)
{
@@ -182,6 +183,15 @@ namespace Newtonsoft.Json }
/// <summary>
+ /// Gets or sets the culture used when reading JSON. Defaults to <see cref="CultureInfo.InvariantCulture"/>.
+ /// </summary>
+ public CultureInfo Culture
+ {
+ get { return _culture ?? CultureInfo.InvariantCulture; }
+ set { _culture = value; }
+ }
+
+ /// <summary>
/// Initializes a new instance of the <see cref="JsonReader"/> class with the specified <see cref="TextReader"/>.
/// </summary>
protected JsonReader()
@@ -473,7 +483,7 @@ namespace Newtonsoft.Json int lineNumber;
int linePosition;
- if (lineInfo != null)
+ if (lineInfo != null && lineInfo.HasLineInfo())
{
lineNumber = lineInfo.LineNumber;
linePosition = lineInfo.LinePosition;
@@ -492,7 +502,7 @@ namespace Newtonsoft.Json if (!message.EndsWith("."))
message += ".";
- if (lineInfo != null)
+ if (lineInfo != null && lineInfo.HasLineInfo())
message += " Line {0}, position {1}.".FormatWith(CultureInfo.InvariantCulture, lineInfo.LineNumber, lineInfo.LinePosition);
return message;
|