Merge branch 'special-properties'
This commit is contained in:
@@ -57,6 +57,25 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
[TestFixture]
|
||||
public class JObjectTests : TestFixtureBase
|
||||
{
|
||||
[Test]
|
||||
public void JObjectWithComments()
|
||||
{
|
||||
string json = @"{ /*comment2*/
|
||||
""Name"": /*comment3*/ ""Apple"" /*comment4*/, /*comment5*/
|
||||
""ExpiryDate"": ""\/Date(1230422400000)\/"",
|
||||
""Price"": 3.99,
|
||||
""Sizes"": /*comment6*/ [ /*comment7*/
|
||||
""Small"", /*comment8*/
|
||||
""Medium"" /*comment9*/,
|
||||
/*comment10*/ ""Large""
|
||||
/*comment11*/ ] /*comment12*/
|
||||
} /*comment13*/";
|
||||
|
||||
JToken o = JToken.Parse(json);
|
||||
|
||||
Assert.AreEqual("Apple", (string) o["Name"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WritePropertyWithNoValue()
|
||||
{
|
||||
|
||||
@@ -44,6 +44,21 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
[TestFixture]
|
||||
public class JTokenReaderTest : TestFixtureBase
|
||||
{
|
||||
[Test]
|
||||
public void ErrorTokenIndex()
|
||||
{
|
||||
JObject json = JObject.Parse(@"{""IntList"":[1, ""two""]}");
|
||||
|
||||
ExceptionAssert.Throws<Exception>(
|
||||
"Could not convert string to integer: two. Path 'IntList[1]', line 1, position 20.",
|
||||
() =>
|
||||
{
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
|
||||
serializer.Deserialize<TraceTestObject>(json.CreateReader());
|
||||
});
|
||||
}
|
||||
|
||||
#if !NET20
|
||||
[Test]
|
||||
public void YahooFinance()
|
||||
|
||||
@@ -49,6 +49,24 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
[TestFixture]
|
||||
public class LinqToJsonTest : TestFixtureBase
|
||||
{
|
||||
[Test]
|
||||
public void JPropertyPath()
|
||||
{
|
||||
JObject o = new JObject
|
||||
{
|
||||
{
|
||||
"person",
|
||||
new JObject
|
||||
{
|
||||
{ "$id", 1 }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
JContainer idProperty = o["person"]["$id"].Parent;
|
||||
Assert.AreEqual("person.$id", idProperty.Path);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ForEach()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user