2
// Copyright (c) 2007 James Newton-King
4
// Permission is hereby granted, free of charge, to any person
5
// obtaining a copy of this software and associated documentation
6
// files (the "Software"), to deal in the Software without
7
// restriction, including without limitation the rights to use,
8
// copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the
10
// Software is furnished to do so, subject to the following
13
// The above copyright notice and this permission notice shall be
14
// included in all copies or substantial portions of the Software.
16
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
// OTHER DEALINGS IN THE SOFTWARE.
27
using System.Collections.Generic;
28
using System.Globalization;
30
using NUnit.Framework;
32
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
33
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
34
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
36
using Newtonsoft.Json.Converters;
37
using Newtonsoft.Json.Linq;
38
using Newtonsoft.Json.Tests.Serialization;
39
using Newtonsoft.Json.Tests.TestObjects;
41
using Newtonsoft.Json.Utilities.LinqBridge;
47
namespace Newtonsoft.Json.Tests.Linq
50
public class LinqToJsonTest : TestFixtureBase
53
public void DoubleValue()
55
JArray j = JArray.Parse("[-1E+4,100.0e-2]");
57
double value = (double)j[0];
58
Assert.AreEqual(-10000d, value);
61
Assert.AreEqual(1d, value);
67
JArray array = new JArray();
68
JValue text = new JValue("Manual text");
69
JValue date = new JValue(new DateTime(2000, 5, 23));
74
string json = array.ToString();
77
// "\/Date(958996800000+1200)\/"
82
public void LinqToJsonDeserialize()
84
JObject o = new JObject(
85
new JProperty("Name", "John Smith"),
86
new JProperty("BirthDate", new DateTime(1983, 3, 20))
89
JsonSerializer serializer = new JsonSerializer();
90
Person p = (Person)serializer.Deserialize(new JTokenReader(o), typeof(Person));
93
Console.WriteLine(p.Name);
97
public void ObjectParse()
103
""500 gigabyte hard drive""
107
JObject o = JObject.Parse(json);
108
IList<JProperty> properties = o.Properties().ToList();
110
Assert.AreEqual("CPU", properties[0].Name);
111
Assert.AreEqual("Intel", (string)properties[0].Value);
112
Assert.AreEqual("Drives", properties[1].Name);
114
JArray list = (JArray)properties[1].Value;
115
Assert.AreEqual(2, list.Children().Count());
116
Assert.AreEqual("DVD read/writer", (string)list.Children().ElementAt(0));
117
Assert.AreEqual("500 gigabyte hard drive", (string)list.Children().ElementAt(1));
119
List<object> parameterValues =
120
(from p in o.Properties()
121
where p.Value is JValue
122
select ((JValue)p.Value).Value).ToList();
124
Assert.AreEqual(1, parameterValues.Count);
125
Assert.AreEqual("Intel", parameterValues[0]);
129
public void CreateLongArray()
131
string json = @"[0,1,2,3,4,5,6,7,8,9]";
133
JArray a = JArray.Parse(json);
134
List<int> list = a.Values<int>().ToList();
136
List<int> expected = new List<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
138
CollectionAssert.AreEqual(expected, list);
142
public void GoogleSearchAPI()
149
GsearchResultClass:""GwebSearch"",
150
unescapedUrl : ""http://www.google.com/"",
151
url : ""http://www.google.com/"",
152
visibleUrl : ""www.google.com"",
154
""http://www.google.com/search?q=cache:zhool8dxBV4J:www.google.com"",
156
titleNoFormatting : ""Google"",
157
content : ""Enables users to search the Web, Usenet, and
158
images. Features include PageRank, caching and translation of
159
results, and an option to find similar pages.""
162
GsearchResultClass:""GwebSearch"",
163
unescapedUrl : ""http://news.google.com/"",
164
url : ""http://news.google.com/"",
165
visibleUrl : ""news.google.com"",
167
""http://www.google.com/search?q=cache:Va_XShOz_twJ:news.google.com"",
168
title : ""Google News"",
169
titleNoFormatting : ""Google News"",
170
content : ""Aggregated headlines and a search engine of many of the world's news sources.""
174
GsearchResultClass:""GwebSearch"",
175
unescapedUrl : ""http://groups.google.com/"",
176
url : ""http://groups.google.com/"",
177
visibleUrl : ""groups.google.com"",
179
""http://www.google.com/search?q=cache:x2uPD3hfkn0J:groups.google.com"",
180
title : ""Google Groups"",
181
titleNoFormatting : ""Google Groups"",
182
content : ""Enables users to search and browse the Usenet
183
archives which consist of over 700 million messages, and post new
188
GsearchResultClass:""GwebSearch"",
189
unescapedUrl : ""http://maps.google.com/"",
190
url : ""http://maps.google.com/"",
191
visibleUrl : ""maps.google.com"",
193
""http://www.google.com/search?q=cache:dkf5u2twBXIJ:maps.google.com"",
194
title : ""Google Maps"",
195
titleNoFormatting : ""Google Maps"",
196
content : ""Provides directions, interactive maps, and
197
satellite/aerial imagery of the United States. Can also search by
198
keyword such as type of business.""
205
GsearchResultClass:""GwebSearch.ad"",
206
title : ""Gartner Symposium/ITxpo"",
207
content1 : ""Meet brilliant Gartner IT analysts"",
208
content2 : ""20-23 May 2007- Barcelona, Spain"",
210
""http://www.google.com/url?sa=L&ai=BVualExYGRo3hD5ianAPJvejjD8-s6ye7kdTwArbI4gTAlrECEAEYASDXtMMFOAFQubWAjvr_____AWDXw_4EiAEBmAEAyAEBgAIB&num=1&q=http://www.gartner.com/it/sym/2007/spr8/spr8.jsp%3Fsrc%3D_spain_07_%26WT.srch%3D1&usg=__CxRH06E4Xvm9Muq13S4MgMtnziY="",
213
""http://www.google.com/uds/css/ad-indicator-on.gif?ai=BVualExYGRo3hD5ianAPJvejjD8-s6ye7kdTwArbI4gTAlrECEAEYASDXtMMFOAFQubWAjvr_____AWDXw_4EiAEBmAEAyAEBgAIB"",
216
""http://www.google.com/url?sa=L&ai=BVualExYGRo3hD5ianAPJvejjD8-s6ye7kdTwArbI4gTAlrECEAEYASDXtMMFOAFQubWAjvr_____AWDXw_4EiAEBmAEAyAEBgAIB&num=1&q=http://www.gartner.com/it/sym/2007/spr8/spr8.jsp%3Fsrc%3D_spain_07_%26WT.srch%3D1&usg=__CxRH06E4Xvm9Muq13S4MgMtnziY="",
218
visibleUrl : ""www.gartner.com""
225
JObject o = JObject.Parse(json);
227
List<JObject> resultObjects = o["results"].Children<JObject>().ToList();
229
Assert.AreEqual(32, resultObjects.Properties().Count());
231
Assert.AreEqual(32, resultObjects.Cast<JToken>().Values().Count());
233
Assert.AreEqual(4, resultObjects.Cast<JToken>().Values("GsearchResultClass").Count());
235
Assert.AreEqual(5, o.PropertyValues().Cast<JArray>().Children().Count());
237
List<string> resultUrls = o["results"].Children().Values<string>("url").ToList();
239
List<string> expectedUrls = new List<string>() { "http://www.google.com/", "http://news.google.com/", "http://groups.google.com/", "http://maps.google.com/" };
241
CollectionAssert.AreEqual(expectedUrls, resultUrls);
243
List<JToken> descendants = o.Descendants().ToList();
244
Assert.AreEqual(89, descendants.Count);
248
public void JTokenToString()
254
""500 gigabyte hard drive""
258
JObject o = JObject.Parse(json);
264
""500 gigabyte hard drive""
268
JArray list = o.Value<JArray>("Drives");
272
""500 gigabyte hard drive""
273
]", list.ToString());
275
JProperty cpuProperty = o.Property("CPU");
276
Assert.AreEqual(@"""CPU"": ""Intel""", cpuProperty.ToString());
278
JProperty drivesProperty = o.Property("Drives");
279
Assert.AreEqual(@"""Drives"": [
281
""500 gigabyte hard drive""
282
]", drivesProperty.ToString());
286
public void JTokenToStringTypes()
288
string json = @"{""Color"":2,""Establised"":new Date(1264118400000),""Width"":1.1,""Employees"":999,""RoomsPerFloor"":[1,2,3,4,5,6,7,8,9],""Open"":false,""Symbol"":""@"",""Mottos"":[""Hello World"",""Ć¶Ć¤Ć¼ĆĆĆ\\'{new Date(12345);}[222]_Āµ@Ā²Ā³~"",null,"" ""],""Cost"":100980.1,""Escape"":""\r\n\t\f\b?{\\r\\n\""'"",""product"":[{""Name"":""Rocket"",""ExpiryDate"":new Date(949532490000),""Price"":0},{""Name"":""Alien"",""ExpiryDate"":new Date(-62135596800000),""Price"":0}]}";
290
JObject o = JObject.Parse(json);
292
Assert.AreEqual(@"""Establised"": new Date(
294
)", o.Property("Establised").ToString());
295
Assert.AreEqual(@"new Date(
297
)", o.Property("Establised").Value.ToString());
298
Assert.AreEqual(@"""Width"": 1.1", o.Property("Width").ToString());
299
Assert.AreEqual(@"1.1", ((JValue)o.Property("Width").Value).ToString(CultureInfo.InvariantCulture));
300
Assert.AreEqual(@"""Open"": false", o.Property("Open").ToString());
301
Assert.AreEqual(@"False", o.Property("Open").Value.ToString());
303
json = @"[null,undefined]";
305
JArray a = JArray.Parse(json);
310
Assert.AreEqual(@"", a.Children().ElementAt(0).ToString());
311
Assert.AreEqual(@"", a.Children().ElementAt(1).ToString());
315
public void CreateJTokenTree()
319
new JProperty("Test1", "Test1Value"),
320
new JProperty("Test2", "Test2Value"),
321
new JProperty("Test3", "Test3Value"),
322
new JProperty("Test4", null)
325
Assert.AreEqual(4, o.Properties().Count());
328
""Test1"": ""Test1Value"",
329
""Test2"": ""Test2Value"",
330
""Test3"": ""Test3Value"",
337
new DateTime(2000, 10, 10, 0, 0, 0, DateTimeKind.Utc),
343
new DateTime(4, 5, 6, 7, 8, 9, DateTimeKind.Utc)
353
Assert.AreEqual(5, a.Count());
356
""Test1"": ""Test1Value"",
357
""Test2"": ""Test2Value"",
358
""Test3"": ""Test3Value"",
361
""2000-10-10T00:00:00Z"",
367
""0004-05-06T07:08:09Z""
379
public string Title { get; set; }
380
public string Description { get; set; }
381
public string Link { get; set; }
382
public IList<string> Categories { get; set; }
385
private List<Post> GetPosts()
387
return new List<Post>()
391
Title = "LINQ to JSON beta",
392
Description = "Annoucing LINQ to JSON",
393
Link = "http://james.newtonking.com/projects/json-net.aspx",
394
Categories = new List<string>() { "Json.NET", "LINQ" }
398
Title = "Json.NET 1.3 + New license + Now on CodePlex",
399
Description = "Annoucing the release of Json.NET 1.3, the MIT license and the source being available on CodePlex",
400
Link = "http://james.newtonking.com/projects/json-net.aspx",
401
Categories = new List<string>() { "Json.NET", "CodePlex" }
407
public void CreateJTokenTreeNested()
409
List<Post> posts = GetPosts();
413
new JProperty("channel",
415
new JProperty("title", "James Newton-King"),
416
new JProperty("link", "http://james.newtonking.com"),
417
new JProperty("description", "James Newton-King's blog."),
418
new JProperty("item",
423
new JProperty("title", p.Title),
424
new JProperty("description", p.Description),
425
new JProperty("link", p.Link),
426
new JProperty("category",
428
from c in p.Categories
429
select new JValue(c)))))))));
431
Console.WriteLine(rss.ToString());
435
// "title": "James Newton-King",
436
// "link": "http://james.newtonking.com",
437
// "description": "James Newton-King's blog.",
440
// "title": "Json.NET 1.3 + New license + Now on CodePlex",
441
// "description": "Annoucing the release of Json.NET 1.3, the MIT license and the source being available on CodePlex",
442
// "link": "http://james.newtonking.com/projects/json-net.aspx",
449
// "title": "LINQ to JSON beta",
450
// "description": "Annoucing LINQ to JSON",
451
// "link": "http://james.newtonking.com/projects/json-net.aspx",
462
from p in rss["channel"]["item"]
463
select p.Value<string>("title");
465
foreach (var item in postTitles)
467
Console.WriteLine(item);
471
//Json.NET 1.3 + New license + Now on CodePlex
474
from c in rss["channel"]["item"].Children()["category"].Values<string>()
476
orderby g.Count() descending
477
select new { Category = g.Key, Count = g.Count() };
479
foreach (var c in categories)
481
Console.WriteLine(c.Category + " - Count: " + c.Count);
484
//Json.NET - Count: 2
486
//CodePlex - Count: 1
490
public void BasicQuerying()
494
""title"": ""James Newton-King"",
495
""link"": ""http://james.newtonking.com"",
496
""description"": ""James Newton-King's blog."",
499
""title"": ""Json.NET 1.3 + New license + Now on CodePlex"",
500
""description"": ""Annoucing the release of Json.NET 1.3, the MIT license and the source being available on CodePlex"",
501
""link"": ""http://james.newtonking.com/projects/json-net.aspx"",
508
""title"": ""LINQ to JSON beta"",
509
""description"": ""Annoucing LINQ to JSON"",
510
""link"": ""http://james.newtonking.com/projects/json-net.aspx"",
520
JObject o = JObject.Parse(json);
522
Assert.AreEqual(null, o["purple"]);
523
Assert.AreEqual(null, o.Value<string>("purple"));
525
CustomAssert.IsInstanceOfType(typeof(JArray), o["channel"]["item"]);
527
Assert.AreEqual(2, o["channel"]["item"].Children()["title"].Count());
528
Assert.AreEqual(0, o["channel"]["item"].Children()["monkey"].Count());
530
Assert.AreEqual("Json.NET 1.3 + New license + Now on CodePlex", (string)o["channel"]["item"][0]["title"]);
532
CollectionAssert.AreEqual(new string[] { "Json.NET 1.3 + New license + Now on CodePlex", "LINQ to JSON beta" }, o["channel"]["item"].Children().Values<string>("title").ToArray());
536
public void JObjectIntIndex()
538
ExceptionAssert.Throws<ArgumentException>("Accessed JObject values with invalid key value: 0. Object property name expected.",
541
JObject o = new JObject();
542
Assert.AreEqual(null, o[0]);
547
public void JArrayStringIndex()
549
ExceptionAssert.Throws<ArgumentException>(@"Accessed JArray values with invalid key value: ""purple"". Array position index expected.",
552
JArray a = new JArray();
553
Assert.AreEqual(null, a["purple"]);
558
public void JConstructorStringIndex()
560
ExceptionAssert.Throws<ArgumentException>(@"Accessed JConstructor values with invalid key value: ""purple"". Argument position index expected.",
563
JConstructor c = new JConstructor("ConstructorValue");
564
Assert.AreEqual(null, c["purple"]);
568
#if !PocketPC && !NET20
570
public void ToStringJsonConverter()
574
new JProperty("Test1", new DateTime(2000, 10, 15, 5, 5, 5, DateTimeKind.Utc)),
575
new JProperty("Test2", new DateTimeOffset(2000, 10, 15, 5, 5, 5, new TimeSpan(11, 11, 0))),
576
new JProperty("Test3", "Test3Value"),
577
new JProperty("Test4", null)
580
JsonSerializer serializer = new JsonSerializer();
581
serializer.Converters.Add(new JavaScriptDateTimeConverter());
582
StringWriter sw = new StringWriter();
583
JsonWriter writer = new JsonTextWriter(sw);
584
writer.Formatting = Formatting.Indented;
585
serializer.Serialize(writer, o);
587
string json = sw.ToString();
596
""Test3"": ""Test3Value"",
602
public void DateTimeOffset()
604
List<DateTimeOffset> testDates = new List<DateTimeOffset> {
605
new DateTimeOffset(new DateTime(100, 1, 1, 1, 1, 1, DateTimeKind.Utc)),
606
new DateTimeOffset(2000, 1, 1, 1, 1, 1, TimeSpan.Zero),
607
new DateTimeOffset(2000, 1, 1, 1, 1, 1, TimeSpan.FromHours(13)),
608
new DateTimeOffset(2000, 1, 1, 1, 1, 1, TimeSpan.FromHours(-3.5)),
611
JsonSerializer jsonSerializer = new JsonSerializer();
613
JTokenWriter jsonWriter;
614
using (jsonWriter = new JTokenWriter())
616
jsonSerializer.Serialize(jsonWriter, testDates);
619
Assert.AreEqual(4, jsonWriter.Token.Children().Count());
624
public void FromObject()
626
List<Post> posts = GetPosts();
628
JObject o = JObject.FromObject(new
632
title = "James Newton-King",
633
link = "http://james.newtonking.com",
634
description = "James Newton-King's blog.",
641
description = p.Description,
643
category = p.Categories
648
Console.WriteLine(o.ToString());
649
CustomAssert.IsInstanceOfType(typeof(JObject), o);
650
CustomAssert.IsInstanceOfType(typeof(JObject), o["channel"]);
651
Assert.AreEqual("James Newton-King", (string)o["channel"]["title"]);
652
Assert.AreEqual(2, o["channel"]["item"].Children().Count());
654
JArray a = JArray.FromObject(new List<int>() { 0, 1, 2, 3, 4 });
655
CustomAssert.IsInstanceOfType(typeof(JArray), a);
656
Assert.AreEqual(5, a.Count());
660
public void FromAnonDictionary()
662
List<Post> posts = GetPosts();
664
JObject o = JObject.FromObject(new
666
channel = new Dictionary<string, object>
668
{ "title", "James Newton-King" },
669
{ "link", "http://james.newtonking.com" },
670
{ "description", "James Newton-King's blog." },
677
description = p.Description,
679
category = p.Categories
685
Console.WriteLine(o.ToString());
686
CustomAssert.IsInstanceOfType(typeof(JObject), o);
687
CustomAssert.IsInstanceOfType(typeof(JObject), o["channel"]);
688
Assert.AreEqual("James Newton-King", (string)o["channel"]["title"]);
689
Assert.AreEqual(2, o["channel"]["item"].Children().Count());
691
JArray a = JArray.FromObject(new List<int>() { 0, 1, 2, 3, 4 });
692
CustomAssert.IsInstanceOfType(typeof(JArray), a);
693
Assert.AreEqual(5, a.Count());
697
public void AsJEnumerable()
700
IJEnumerable<JToken> enumerable = null;
702
enumerable = o.AsJEnumerable();
703
Assert.IsNull(enumerable);
707
new JProperty("Test1", new DateTime(2000, 10, 15, 5, 5, 5, DateTimeKind.Utc)),
708
new JProperty("Test2", "Test2Value"),
709
new JProperty("Test3", null)
712
enumerable = o.AsJEnumerable();
713
Assert.IsNotNull(enumerable);
714
Assert.AreEqual(o, enumerable);
716
DateTime d = enumerable["Test1"].Value<DateTime>();
718
Assert.AreEqual(new DateTime(2000, 10, 15, 5, 5, 5, DateTimeKind.Utc), d);
721
#if !(NET20 || NET35 || SILVERLIGHT || PORTABLE)
723
public void CovariantIJEnumerable()
725
IEnumerable<JObject> o = new[]
727
JObject.FromObject(new {First = 1, Second = 2}),
728
JObject.FromObject(new {First = 1, Second = 2})
731
IJEnumerable<JToken> values = o.Properties();
732
Assert.AreEqual(4, values.Count());
737
public void ChildrenExtension()
741
""title"": ""James Newton-King"",
742
""link"": ""http://james.newtonking.com"",
743
""description"": ""James Newton-King's blog."",
746
""title"": ""Json.NET 1.3 + New license + Now on CodePlex"",
747
""description"": ""Annoucing the release of Json.NET 1.3, the MIT license and the source being available on CodePlex"",
748
""link"": ""http://james.newtonking.com/projects/json-net.aspx"",
755
""title"": ""LINQ to JSON beta"",
756
""description"": ""Annoucing LINQ to JSON"",
757
""link"": ""http://james.newtonking.com/projects/json-net.aspx"",
766
""title"": ""James Newton-King"",
767
""link"": ""http://james.newtonking.com"",
768
""description"": ""James Newton-King's blog."",
771
""title"": ""Json.NET 1.3 + New license + Now on CodePlex"",
772
""description"": ""Annoucing the release of Json.NET 1.3, the MIT license and the source being available on CodePlex"",
773
""link"": ""http://james.newtonking.com/projects/json-net.aspx"",
780
""title"": ""LINQ to JSON beta"",
781
""description"": ""Annoucing LINQ to JSON"",
782
""link"": ""http://james.newtonking.com/projects/json-net.aspx"",
792
JArray o = JArray.Parse(json);
794
Assert.AreEqual(4, o.Children()["item"].Children()["title"].Count());
795
CollectionAssert.AreEqual(new string[]
797
"Json.NET 1.3 + New license + Now on CodePlex",
799
"Json.NET 1.3 + New license + Now on CodePlex",
802
o.Children()["item"].Children()["title"].Values<string>().ToArray());
806
public void UriGuidTimeSpanTestClassEmptyTest()
808
UriGuidTimeSpanTestClass c1 = new UriGuidTimeSpanTestClass();
809
JObject o = JObject.FromObject(c1);
812
""Guid"": ""00000000-0000-0000-0000-000000000000"",
813
""NullableGuid"": null,
814
""TimeSpan"": ""00:00:00"",
815
""NullableTimeSpan"": null,
819
UriGuidTimeSpanTestClass c2 = o.ToObject<UriGuidTimeSpanTestClass>();
820
Assert.AreEqual(c1.Guid, c2.Guid);
821
Assert.AreEqual(c1.NullableGuid, c2.NullableGuid);
822
Assert.AreEqual(c1.TimeSpan, c2.TimeSpan);
823
Assert.AreEqual(c1.NullableTimeSpan, c2.NullableTimeSpan);
824
Assert.AreEqual(c1.Uri, c2.Uri);
828
public void UriGuidTimeSpanTestClassValuesTest()
830
UriGuidTimeSpanTestClass c1 = new UriGuidTimeSpanTestClass
832
Guid = new Guid("1924129C-F7E0-40F3-9607-9939C531395A"),
833
NullableGuid = new Guid("9E9F3ADF-E017-4F72-91E0-617EBE85967D"),
834
TimeSpan = TimeSpan.FromDays(1),
835
NullableTimeSpan = TimeSpan.FromHours(1),
836
Uri = new Uri("http://testuri.com")
838
JObject o = JObject.FromObject(c1);
841
""Guid"": ""1924129c-f7e0-40f3-9607-9939c531395a"",
842
""NullableGuid"": ""9e9f3adf-e017-4f72-91e0-617ebe85967d"",
843
""TimeSpan"": ""1.00:00:00"",
844
""NullableTimeSpan"": ""01:00:00"",
845
""Uri"": ""http://testuri.com/""
848
UriGuidTimeSpanTestClass c2 = o.ToObject<UriGuidTimeSpanTestClass>();
849
Assert.AreEqual(c1.Guid, c2.Guid);
850
Assert.AreEqual(c1.NullableGuid, c2.NullableGuid);
851
Assert.AreEqual(c1.TimeSpan, c2.TimeSpan);
852
Assert.AreEqual(c1.NullableTimeSpan, c2.NullableTimeSpan);
853
Assert.AreEqual(c1.Uri, c2.Uri);
857
public void ParseWithPrecendingComments()
859
string json = @"/* blah */ {'hi':'hi!'}";
860
JObject o = JObject.Parse(json);
861
Assert.AreEqual("hi!", (string)o["hi"]);
863
json = @"/* blah */ ['hi!']";
864
JArray a = JArray.Parse(json);
865
Assert.AreEqual("hi!", (string)a[0]);
b'\\ No newline at end of file'