I am using fastJSON and I ran into a problem. I cannot take a JSON string and convert it to a collection of objects.
I thought it could handle this but maybe I am doing it wrong or misunderstood.
Handles polymorphic collections of objects
Here is an example I did in a C# cmd line app (just download the .cs files and add to a project and copy the follow code to test).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
List<Class1> store = new List<Class1>();
for (int i = 0; i < 3; i++)
{
Class1 c = new Class1();
c.Name = "test";
c.Start = DateTime.Now;
store.Add(c);
}
string jsonResult = fastJSON.JSON.Instance.ToJSON(store);
List<Class1> backToObject = fastJSON.JSON.Instance.
ToObject<List<Class1>>(jsonResult);
}
}
public class Class1
{
public string Name { get; set; }
public DateTime Start { get; set; }
}
}
backToObject
is always null.
I am using fastJSON because I need something that really has no dependencies on .NET libraries and I am using monodroid (and probably later monotouch) and it is very picky in what you can use and can't use.
For instance I can not use the Json.net library (I think there is one for monodroid but I trying to make my code reusable for when I do the iPhone part).