diff --git a/Src/Newtonsoft.Json.Tests/Linq/JTokenReaderTest.cs b/Src/Newtonsoft.Json.Tests/Linq/JTokenReaderTest.cs index 42a6c059..40556f12 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JTokenReaderTest.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JTokenReaderTest.cs @@ -614,5 +614,117 @@ namespace Newtonsoft.Json.Tests.Linq Assert.AreEqual(null, reader.ValueType); Assert.AreEqual(null, reader.Value); } + + [Test] + public void InitialPath_PropertyBase_PropertyToken() + { + JObject o = new JObject + { + { "prop1", true } + }; + + JTokenReader reader = new JTokenReader(o, "baseprop"); + + Assert.AreEqual("baseprop", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("baseprop", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("baseprop.prop1", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("baseprop.prop1", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("baseprop", reader.Path); + + Assert.IsFalse(reader.Read()); + Assert.AreEqual("baseprop", reader.Path); + } + + [Test] + public void InitialPath_ArrayBase_PropertyToken() + { + JObject o = new JObject + { + { "prop1", true } + }; + + JTokenReader reader = new JTokenReader(o, "[0]"); + + Assert.AreEqual("[0]", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("[0]", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("[0].prop1", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("[0].prop1", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("[0]", reader.Path); + + Assert.IsFalse(reader.Read()); + Assert.AreEqual("[0]", reader.Path); + } + + [Test] + public void InitialPath_PropertyBase_ArrayToken() + { + JArray a = new JArray + { + 1, 2 + }; + + JTokenReader reader = new JTokenReader(a, "baseprop"); + + Assert.AreEqual("baseprop", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("baseprop", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("baseprop[0]", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("baseprop[1]", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("baseprop", reader.Path); + + Assert.IsFalse(reader.Read()); + Assert.AreEqual("baseprop", reader.Path); + } + + [Test] + public void InitialPath_ArrayBase_ArrayToken() + { + JArray a = new JArray + { + 1, 2 + }; + + JTokenReader reader = new JTokenReader(a, "[0]"); + + Assert.AreEqual("[0]", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("[0]", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("[0][0]", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("[0][1]", reader.Path); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual("[0]", reader.Path); + + Assert.IsFalse(reader.Read()); + Assert.AreEqual("[0]", reader.Path); + } } } \ No newline at end of file diff --git a/Src/Newtonsoft.Json/Bson/BsonWriter.cs b/Src/Newtonsoft.Json/Bson/BsonWriter.cs index a0ea088b..16196a5a 100644 --- a/Src/Newtonsoft.Json/Bson/BsonWriter.cs +++ b/Src/Newtonsoft.Json/Bson/BsonWriter.cs @@ -139,7 +139,7 @@ namespace Newtonsoft.Json.Bson } /// - /// Writes the beginning of a Json array. + /// Writes the beginning of a JSON array. /// public override void WriteStartArray() { @@ -149,7 +149,7 @@ namespace Newtonsoft.Json.Bson } /// - /// Writes the beginning of a Json object. + /// Writes the beginning of a JSON object. /// public override void WriteStartObject() { @@ -159,7 +159,7 @@ namespace Newtonsoft.Json.Bson } /// - /// Writes the property name of a name/value pair on a Json object. + /// Writes the property name of a name/value pair on a JSON object. /// /// The name of the property. public override void WritePropertyName(string name) diff --git a/Src/Newtonsoft.Json/JsonException.cs b/Src/Newtonsoft.Json/JsonException.cs index edf123e5..7072ffd3 100644 --- a/Src/Newtonsoft.Json/JsonException.cs +++ b/Src/Newtonsoft.Json/JsonException.cs @@ -33,7 +33,7 @@ using Newtonsoft.Json.Utilities; namespace Newtonsoft.Json { /// - /// The exception thrown when an error occurs during Json serialization or deserialization. + /// The exception thrown when an error occurs during JSON serialization or deserialization. /// #if !(NETFX_CORE || PORTABLE40 || PORTABLE) [Serializable] diff --git a/Src/Newtonsoft.Json/JsonReaderException.cs b/Src/Newtonsoft.Json/JsonReaderException.cs index 034a7e5a..bd871062 100644 --- a/Src/Newtonsoft.Json/JsonReaderException.cs +++ b/Src/Newtonsoft.Json/JsonReaderException.cs @@ -31,7 +31,7 @@ using Newtonsoft.Json.Utilities; namespace Newtonsoft.Json { /// - /// The exception thrown when an error occurs while reading Json text. + /// The exception thrown when an error occurs while reading JSON text. /// #if !(NETFX_CORE || PORTABLE || PORTABLE40) [Serializable] diff --git a/Src/Newtonsoft.Json/JsonSerializationException.cs b/Src/Newtonsoft.Json/JsonSerializationException.cs index 2c1099f7..5680a541 100644 --- a/Src/Newtonsoft.Json/JsonSerializationException.cs +++ b/Src/Newtonsoft.Json/JsonSerializationException.cs @@ -31,7 +31,7 @@ using System.Text; namespace Newtonsoft.Json { /// - /// The exception thrown when an error occurs during Json serialization or deserialization. + /// The exception thrown when an error occurs during JSON serialization or deserialization. /// #if !(NETFX_CORE || PORTABLE40 || PORTABLE) [Serializable] diff --git a/Src/Newtonsoft.Json/JsonSerializer.cs b/Src/Newtonsoft.Json/JsonSerializer.cs index 10c42978..c8cb112b 100644 --- a/Src/Newtonsoft.Json/JsonSerializer.cs +++ b/Src/Newtonsoft.Json/JsonSerializer.cs @@ -374,7 +374,7 @@ namespace Newtonsoft.Json } /// - /// Get or set how and values are formatting when writing JSON text. + /// Get or set how and values are formatted when writing JSON text, and the expected date format when reading JSON text. /// public virtual string DateFormatString { @@ -644,7 +644,7 @@ namespace Newtonsoft.Json } /// - /// Deserializes the Json structure contained by the specified . + /// Deserializes the JSON structure contained by the specified . /// /// The that contains the JSON structure to deserialize. /// The being deserialized. @@ -654,7 +654,7 @@ namespace Newtonsoft.Json } /// - /// Deserializes the Json structure contained by the specified + /// Deserializes the JSON structure contained by the specified /// into an instance of the specified type. /// /// The containing the object. @@ -666,7 +666,7 @@ namespace Newtonsoft.Json } /// - /// Deserializes the Json structure contained by the specified + /// Deserializes the JSON structure contained by the specified /// into an instance of the specified type. /// /// The containing the object. @@ -678,7 +678,7 @@ namespace Newtonsoft.Json } /// - /// Deserializes the Json structure contained by the specified + /// Deserializes the JSON structure contained by the specified /// into an instance of the specified type. /// /// The containing the object. @@ -810,10 +810,10 @@ namespace Newtonsoft.Json } /// - /// Serializes the specified and writes the Json structure + /// Serializes the specified and writes the JSON structure /// to a Stream using the specified . /// - /// The used to write the Json structure. + /// The used to write the JSON structure. /// The to serialize. public void Serialize(TextWriter textWriter, object value) { @@ -821,10 +821,10 @@ namespace Newtonsoft.Json } /// - /// Serializes the specified and writes the Json structure + /// Serializes the specified and writes the JSON structure /// to a Stream using the specified . /// - /// The used to write the Json structure. + /// The used to write the JSON structure. /// The to serialize. /// /// The type of the value being serialized. @@ -837,10 +837,10 @@ namespace Newtonsoft.Json } /// - /// Serializes the specified and writes the Json structure + /// Serializes the specified and writes the JSON structure /// to a Stream using the specified . /// - /// The used to write the Json structure. + /// The used to write the JSON structure. /// The to serialize. /// /// The type of the value being serialized. @@ -853,10 +853,10 @@ namespace Newtonsoft.Json } /// - /// Serializes the specified and writes the Json structure + /// Serializes the specified and writes the JSON structure /// to a Stream using the specified . /// - /// The used to write the Json structure. + /// The used to write the JSON structure. /// The to serialize. public void Serialize(JsonWriter jsonWriter, object value) { diff --git a/Src/Newtonsoft.Json/JsonSerializerSettings.cs b/Src/Newtonsoft.Json/JsonSerializerSettings.cs index 96949e6d..089729c4 100644 --- a/Src/Newtonsoft.Json/JsonSerializerSettings.cs +++ b/Src/Newtonsoft.Json/JsonSerializerSettings.cs @@ -234,7 +234,7 @@ namespace Newtonsoft.Json } /// - /// Get or set how and values are formatting when writing JSON text. + /// Get or set how and values are formatted when writing JSON text, and the expected date format when reading JSON text. /// public string DateFormatString { diff --git a/Src/Newtonsoft.Json/JsonTextWriter.cs b/Src/Newtonsoft.Json/JsonTextWriter.cs index 26605612..2fdd8372 100644 --- a/Src/Newtonsoft.Json/JsonTextWriter.cs +++ b/Src/Newtonsoft.Json/JsonTextWriter.cs @@ -160,7 +160,7 @@ namespace Newtonsoft.Json } /// - /// Writes the beginning of a Json object. + /// Writes the beginning of a JSON object. /// public override void WriteStartObject() { @@ -170,7 +170,7 @@ namespace Newtonsoft.Json } /// - /// Writes the beginning of a Json array. + /// Writes the beginning of a JSON array. /// public override void WriteStartArray() { @@ -215,7 +215,7 @@ namespace Newtonsoft.Json } /// - /// Writes the property name of a name/value pair on a Json object. + /// Writes the property name of a name/value pair on a JSON object. /// /// The name of the property. public override void WritePropertyName(string name) diff --git a/Src/Newtonsoft.Json/JsonToken.cs b/Src/Newtonsoft.Json/JsonToken.cs index 5e1e47f6..aa93ce28 100644 --- a/Src/Newtonsoft.Json/JsonToken.cs +++ b/Src/Newtonsoft.Json/JsonToken.cs @@ -30,7 +30,7 @@ using System.Text; namespace Newtonsoft.Json { /// - /// Specifies the type of Json token. + /// Specifies the type of JSON token. /// public enum JsonToken { diff --git a/Src/Newtonsoft.Json/JsonWriter.cs b/Src/Newtonsoft.Json/JsonWriter.cs index b6de6925..689a5652 100644 --- a/Src/Newtonsoft.Json/JsonWriter.cs +++ b/Src/Newtonsoft.Json/JsonWriter.cs @@ -353,7 +353,7 @@ namespace Newtonsoft.Json } /// - /// Writes the beginning of a Json object. + /// Writes the beginning of a JSON object. /// public virtual void WriteStartObject() { @@ -361,7 +361,7 @@ namespace Newtonsoft.Json } /// - /// Writes the end of a Json object. + /// Writes the end of a JSON object. /// public virtual void WriteEndObject() { @@ -369,7 +369,7 @@ namespace Newtonsoft.Json } /// - /// Writes the beginning of a Json array. + /// Writes the beginning of a JSON array. /// public virtual void WriteStartArray() { @@ -421,7 +421,7 @@ namespace Newtonsoft.Json } /// - /// Writes the end of the current Json object or array. + /// Writes the end of the current JSON object or array. /// public virtual void WriteEnd() { diff --git a/Src/Newtonsoft.Json/JsonWriterException.cs b/Src/Newtonsoft.Json/JsonWriterException.cs index a955e222..4ed62c1a 100644 --- a/Src/Newtonsoft.Json/JsonWriterException.cs +++ b/Src/Newtonsoft.Json/JsonWriterException.cs @@ -31,7 +31,7 @@ using System.Text; namespace Newtonsoft.Json { /// - /// The exception thrown when an error occurs while reading Json text. + /// The exception thrown when an error occurs while reading JSON text. /// #if !(NETFX_CORE || PORTABLE40 || PORTABLE) [Serializable] diff --git a/Src/Newtonsoft.Json/Linq/JTokenReader.cs b/Src/Newtonsoft.Json/Linq/JTokenReader.cs index 726bd02a..349ecad2 100644 --- a/Src/Newtonsoft.Json/Linq/JTokenReader.cs +++ b/Src/Newtonsoft.Json/Linq/JTokenReader.cs @@ -348,8 +348,7 @@ namespace Newtonsoft.Json.Linq if (string.IsNullOrEmpty(path)) return _initialPath; - if (_initialPath.EndsWith(']') - || path.StartsWith('[')) + if (path.StartsWith('[')) path = _initialPath + path; else path = _initialPath + "." + path; diff --git a/Src/Newtonsoft.Json/Linq/JTokenWriter.cs b/Src/Newtonsoft.Json/Linq/JTokenWriter.cs index bbe985b8..a2dfbe86 100644 --- a/Src/Newtonsoft.Json/Linq/JTokenWriter.cs +++ b/Src/Newtonsoft.Json/Linq/JTokenWriter.cs @@ -101,7 +101,7 @@ namespace Newtonsoft.Json.Linq } /// - /// Writes the beginning of a Json object. + /// Writes the beginning of a JSON object. /// public override void WriteStartObject() { @@ -131,7 +131,7 @@ namespace Newtonsoft.Json.Linq } /// - /// Writes the beginning of a Json array. + /// Writes the beginning of a JSON array. /// public override void WriteStartArray() { @@ -161,7 +161,7 @@ namespace Newtonsoft.Json.Linq } /// - /// Writes the property name of a name/value pair on a Json object. + /// Writes the property name of a name/value pair on a JSON object. /// /// The name of the property. public override void WritePropertyName(string name)