This project has moved and is read-only. For the latest updates, please go here. in MonoTouch error

Nov 14, 2012 at 9:37 PM

Hey there,

I'm using in my first monotouch project to map incoming json data to my objectmodel. It all worked flawlessly well until I went a bit further and put some one-to-many relations in my object model.

Imagine a Json like this
(this Json is further called Project)
 id: 123
 groups: [
    name: "foo",
    buyers: [{id:1},{id:2}]
    name: "bar",
    buyers: [{id:2},{id:3}]

I rebuild the exact same structure in my Objects using List<Group> or List<Buyer> in Project/Group.

Deserializing the groups worked well but the deserialisation of the third depth layer "buyers" just keeps crashing. The app just crashes and exits with a Segmentation Fault coming from within

The first 3 Lines of the stacktrace are:

  at Newtonsoft.Json.Utilities.CollectionWrapper`1.get_Count () <0x00157>
  at Newtonsoft.Json.Utilities.CollectionWrapper`1.System.Collections.IList.Add (object) <0x0013b>
  at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList (Newtonsoft.Json.Utilities.IWrappedCollection,Newtonsoft.Json.JsonReader,string,Newtonsoft.Json.Serialization.JsonArrayContract) [0x000ad] in /Users/szahn/Projects/doqume-mobile/Newtonsoft.Json-master/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:749

I tried all versions of including the "special" Monotouch optimized one I found on github. They all work the same.

My Deserialisation call looks like this:
T object = JsonConvert.DeserializeObject<T>(jsonAsString);

where T is a generic parameter.

PLEASE guys! Help me out with this... :(

Nov 15, 2012 at 9:08 AM

the code works perfectly well in the just crashes on the device...