//[Fact(Skip = "System.TypeLoadException : The generic type 'System.IEquatable`1' was used with an invalid instantiation in assembly 'System.Private.CoreLib")] public void NonAllocatingRead() { JsonDynamicObject json = JsonDynamicObject.Parse(new Utf8Span("{\"First\":\"John\",\"Age\":25}")); Assert.Equal("John", json.First().ToString()); Assert.Equal(25U, json.Age()); }
public void NonAllocatingRead() { var jsonText = new Utf8String("{\"First\":\"John\",\"Age\":25}"); JsonDynamicObject json = JsonDynamicObject.Parse(jsonText); Assert.Equal(new Utf8String("John"), json.First()); Assert.Equal(25U, json.Age()); }
//[Fact(Skip = "System.TypeLoadException : The generic type 'System.IEquatable`1' was used with an invalid instantiation in assembly 'System.Private.CoreLib")] public void NestedEagerWrite() { var jsonText = new Utf8Span("{\"FirstName\":\"John\",\"LastName\":\"Smith\",\"Address\":{\"Street\":\"21 2nd Street\",\"City\":\"New York\",\"State\":\"NY\",\"Zip\":\"10021-3100\"},\"IsAlive\":true,\"Age\":25,\"Spouse\":null}"); JsonDynamicObject json = JsonDynamicObject.Parse(jsonText, 100); var formatter = new ArrayFormatter(1024, SymbolTable.InvariantUtf8); formatter.Append(json); var formattedText = new Utf8Span(formatter.Formatted); // The follwoing check only works given the current implmentation of Dictionary. // If the implementation changes, the properties might round trip to different places in the JSON text. Assert.Equal(jsonText.ToString(), formattedText.ToString()); }
//[Fact(Skip = "System.TypeLoadException : The generic type 'System.IEquatable`1' was used with an invalid instantiation in assembly 'System.Private.CoreLib")] public void NestedEagerRead() { dynamic json = JsonDynamicObject.Parse(new Utf8Span("{ \"FirstName\": \"John\", \"LastName\": \"Smith\", \"Address\": { \"Street\": \"21 2nd Street\", \"City\": \"New York\", \"State\": \"NY\", \"Zip\": \"10021-3100\" }, \"IsAlive\": true, \"Age\": 25, \"Spouse\":null }")); Assert.Equal("John", json.FirstName); Assert.Equal("Smith", json.LastName); Assert.Equal(true, json.IsAlive); Assert.Equal(25, json.Age); Assert.Equal(null, json.Spouse); Assert.Equal(6, json.Count); dynamic address = json.Address; Assert.Equal("21 2nd Street", address.Street); Assert.Equal("New York", address.City); Assert.Equal("NY", address.State); Assert.Equal("10021-3100", address.Zip); Assert.Equal(4, address.Count); }