Skip to content

Instantly share code, notes, and snippets.

@GraemeF
Created January 9, 2011 10:36
Show Gist options
  • Save GraemeF/771591 to your computer and use it in GitHub Desktop.
Save GraemeF/771591 to your computer and use it in GitHub Desktop.
Failing test for JsonFx deserializing a List<T>
namespace Tests
{
using System.Collections.Generic;
using System.Linq;
using JsonFx.Json;
using Should.Fluent;
using Xunit;
public class JsonFxTests
{
[Fact]
public void Read__ReadsAList()
{
string json = "{\"Bars\":[{\"Baz\":\"Test\"}]}";
// this gives JsonFx.Serialization.DeserializationException: JsonFx.Serialization.DeserializationException : Error converting System.Collections.Generic.List`1[[System.Object]] to System.Collections.Generic.List`1[[Tests.Bar]]
var result = new JsonReader().Read<Foo>(json);
result.Bars.Single().Baz.Should().Equal("Test");
}
}
public class Foo
{
public List<Bar> Bars { get; set; }
}
public class Bar
{
public string Baz { get; set; }
}
}
@peroon
Copy link

peroon commented Dec 10, 2014

JsonFx desirializing can't use List ?
Instead of List, Array is deserialized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment