-Changed LINQ to JSON load methods to support reading past preceding comments
This commit is contained in:
@@ -803,6 +803,7 @@ keyword such as type of business.""
|
||||
o.Children()["item"].Children()["title"].Values<string>().ToArray());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UriGuidTimeSpanTestClassEmptyTest()
|
||||
{
|
||||
UriGuidTimeSpanTestClass c1 = new UriGuidTimeSpanTestClass();
|
||||
@@ -824,6 +825,7 @@ keyword such as type of business.""
|
||||
Assert.AreEqual(c1.Uri, c2.Uri);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UriGuidTimeSpanTestClassValuesTest()
|
||||
{
|
||||
UriGuidTimeSpanTestClass c1 = new UriGuidTimeSpanTestClass
|
||||
@@ -851,5 +853,17 @@ keyword such as type of business.""
|
||||
Assert.AreEqual(c1.NullableTimeSpan, c2.NullableTimeSpan);
|
||||
Assert.AreEqual(c1.Uri, c2.Uri);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ParseWithPrecendingComments()
|
||||
{
|
||||
string json = @"/* blah */ {'hi':'hi!'}";
|
||||
JObject o = JObject.Parse(json);
|
||||
Assert.AreEqual("hi!", (string)o["hi"]);
|
||||
|
||||
json = @"/* blah */ ['hi!']";
|
||||
JArray a = JArray.Parse(json);
|
||||
Assert.AreEqual("hi!", (string)a[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,5 +72,5 @@ using System.Security;
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("4.5.0.0")]
|
||||
#if !PocketPC
|
||||
[assembly: AssemblyFileVersion("4.5.7.15114")]
|
||||
[assembly: AssemblyFileVersion("4.5.7.15115")]
|
||||
#endif
|
||||
|
||||
@@ -113,6 +113,12 @@ namespace Newtonsoft.Json.Linq
|
||||
if (!reader.Read())
|
||||
throw JsonReaderException.Create(reader, "Error reading JArray from JsonReader.");
|
||||
}
|
||||
|
||||
while (reader.TokenType == JsonToken.Comment)
|
||||
{
|
||||
reader.Read();
|
||||
}
|
||||
|
||||
if (reader.TokenType != JsonToken.StartArray)
|
||||
throw JsonReaderException.Create(reader, "Error reading JArray from JsonReader. Current JsonReader item is not an array: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
|
||||
|
||||
|
||||
@@ -187,6 +187,11 @@ namespace Newtonsoft.Json.Linq
|
||||
throw JsonReaderException.Create(reader, "Error reading JConstructor from JsonReader.");
|
||||
}
|
||||
|
||||
while (reader.TokenType == JsonToken.Comment)
|
||||
{
|
||||
reader.Read();
|
||||
}
|
||||
|
||||
if (reader.TokenType != JsonToken.StartConstructor)
|
||||
throw JsonReaderException.Create(reader, "Error reading JConstructor from JsonReader. Current JsonReader item is not a constructor: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
|
||||
|
||||
|
||||
@@ -292,6 +292,11 @@ namespace Newtonsoft.Json.Linq
|
||||
throw JsonReaderException.Create(reader, "Error reading JObject from JsonReader.");
|
||||
}
|
||||
|
||||
while (reader.TokenType == JsonToken.Comment)
|
||||
{
|
||||
reader.Read();
|
||||
}
|
||||
|
||||
if (reader.TokenType != JsonToken.StartObject)
|
||||
{
|
||||
throw JsonReaderException.Create(reader, "Error reading JObject from JsonReader. Current JsonReader item is not an object: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
|
||||
|
||||
@@ -229,6 +229,12 @@ namespace Newtonsoft.Json.Linq
|
||||
if (!reader.Read())
|
||||
throw JsonReaderException.Create(reader, "Error reading JProperty from JsonReader.");
|
||||
}
|
||||
|
||||
while (reader.TokenType == JsonToken.Comment)
|
||||
{
|
||||
reader.Read();
|
||||
}
|
||||
|
||||
if (reader.TokenType != JsonToken.PropertyName)
|
||||
throw JsonReaderException.Create(reader, "Error reading JProperty from JsonReader. Current JsonReader item is not a property: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
|
||||
|
||||
|
||||
@@ -1222,7 +1222,6 @@ namespace Newtonsoft.Json.Linq
|
||||
if (!JsonReader.IsStartToken(reader.TokenType))
|
||||
return new JValue(reader.Value);
|
||||
|
||||
// TODO: loading constructor and parameters?
|
||||
throw JsonReaderException.Create(reader, "Error reading JToken from JsonReader. Unexpected token: {0}".FormatWith(CultureInfo.InvariantCulture, reader.TokenType));
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ using System.Security;
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("4.5.0.0")]
|
||||
#if !PocketPC
|
||||
[assembly: AssemblyFileVersion("4.5.7.15114")]
|
||||
[assembly: AssemblyFileVersion("4.5.7.15115")]
|
||||
#endif
|
||||
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
Reference in New Issue
Block a user