Search Unity

JSON .NET for Unity

Discussion in 'Assets and Asset Store' started by Dustin-Horne, Sep 13, 2013.

  1. Dukobpa3

    Dukobpa3

    Joined:
    May 21, 2015
    Posts:
    3
    Hi guys, i have the following issue, would anyone help me with it?
    It is iOS build.

    Code (CSharp):
    1. ArgumentNullException: Argument cannot be null.
    2.  
    3. Parameter name: method
    4.  
    5.   at Newtonsoft.Json.Serialization.ExtensionDataGetter..ctor (System.Object object, IntPtr method) [0x00000] in <filename unknown>:0
    6.  
    7.   at Newtonsoft.Json.Serialization.JsonArrayContract.CreateWrapper (System.Object list) [0x00000] in <filename unknown>:0
    8.  
    9.   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewList (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Boolean& createdFromNonDefaultCreator) [0x00000] in <filename unknown>:0
    10.  
    11.   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    12.  
    13.   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <filename unknown>:0
    14.  
    15.   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    16.  
    17.   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x00000] in <filename unknown>:0
    18.  
    19.   at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <filename unknown>:0
    20.  
    21.   at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <filename unknown>:0
    22.  
    23.   at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <filename unknown>:0
    24.  
    25.   at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0
    26.  
    27.   at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0
    28.  
    29.   at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value) [0x00000] in <filename unknown>:0
    30.  
    31.   at com.playtika.dice.legends.model.serialization.JsonSerializer.DeserializeObject[T] (System.String text) [0x00000] in <filename unknown>:0
    32.  
    33.   at com.playtika.dice.legends.service.restclient.RestClient.Get[TResponse] (System.String url, IDictionary`2 parameters, System.Action`1 responseHandler) [0x00000] in <filename unknown>:0
    34.  
    35.   at com.playtika.dice.legends.service.restclient.RestClient.CoroutineCallback[TResponse] (UnityEngine.WWW www, System.Action`1 complete) [0x00000] in <filename unknown>:0
    36.  
    37.   at com.playtika.dice.legends.service.restclient.RestClient+<Get>c__AnonStorey55`1[TResponse].<>m__E0 (UnityEngine.WWW www) [0x00000] in <filename unknown>:0
    38.  
    39.   at com.playtika.dice.legends.service.restservice.RestService+<WaitLoadingComplete>c__Iterator14.MoveNext () [0x00000] in <filename unknown>:0
    40.  
    41. UnityEngine.Debug:LogException(Exception, Object)
    42.  
    43. com.playtika.dice.legends.util.DlLogger:LogException(Exception, Object)
    44.  
    45. com.playtika.dice.legends.service.restservice.<WaitLoadingComplete>c__Iterator14:MoveNext()
     
    Last edited: Nov 22, 2016
  2. Dukobpa3

    Dukobpa3

    Joined:
    May 21, 2015
    Posts:
    3
    Changed in one place IList<Some> to IEnumerable<Some> and now it works.
     
  3. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Sorry it's been a little crazy with the holidays. Not yet and I'm looking at it. Do you get the same behaviour in the editor or is it just on IL2CPP builds?
     
  4. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Yeah it looks to me like that was a constructor that got stripped. Most times when you see the "..ctor" it's a dead giveaway that it's expecting there to be a constructor there and it's missing for something. I'll run some tests with IList and see if there's something I need to add to my links.xml file to try to prevent it from being stripped.
     
  5. adamt

    adamt

    Joined:
    Apr 1, 2014
    Posts:
    116
    Thanks for the reply, Dustin. I get the same behavior in both Unity and player builds.
     
  6. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Just a quick support update. I am a couple of days delayed still. My office of is dead and I've ordered a replacement cpu and motherboard but it leaves me essentially dead in the water for a couple more days.
     
  7. anuj

    anuj

    Joined:
    Jun 15, 2015
    Posts:
    28
    hi,
    i tried to import json.net in my project which otherwise is compiling ok with il2cpp . but after importing json.net il2cpp fails to compile apk
    unity 5.5 release version
    json.net latest from asset store
    if i delete json.net folder from project il2cpp compiles ok
     
  8. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Are you importing the latest version from the asset store? I haven't tested 5.5 yet so I'll have to give it a go and make sure they didn't change anything that would break the assembly mapping. What's the error you're receiving?
     
  9. anuj

    anuj

    Joined:
    Jun 15, 2015
    Posts:
    28
    i will have to reimport it to get the error , and yes its latest version of json.net , straight from the asset store
    platform is android il2cpp. ill try to post error in a hour
     
  10. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Ok, it's possible I missed the assembly mapping for il2cpp on Android. It's easy enough to add. If that's the error, will need to make sure the assembly in the /assemblies/aot folder is mapped to Android for both .net and il2cpp backends.
     
  11. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Bent socket pin makes me sad.
    Screenshot_20161205-201153.png IMG_20161205_201436.jpg IMG_20161205_201404.jpg
     

    Attached Files:

  12. anuj

    anuj

    Joined:
    Jun 15, 2015
    Posts:
    28
    hi ,
    Updates : i finally re-imported the asset from asset store again and for some reason its working now
     
    Dustin-Horne likes this.
  13. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Hi Dustin, any chance the asset working for UWP (windows 10) ?

    I have tried it and it seems to have a lots of error.
     
  14. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Could you show me the errors and is this Unity 5.5? It does (should) work with UWP, but it's possible something changed.
     
  15. jacksoni

    jacksoni

    Joined:
    Dec 16, 2016
    Posts:
    1
    It is a very profitable post for me. I’ve enjoyed reading the post. It is very informative and useful post. I would like to visit the post once more its valuable content json converter
     
  16. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Hmmm... Last post looks like spam, but links to a valid (as far as I can tell) json inspector thing.
     
  17. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,944
    @Dustin-Horne,

    My json object has a property first_name, while my class property is FirstName.
    It doesnt get auto deserialize. How can i fix that?
     
  18. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Add a JsonProperty attribute to your FirstName property on your class like this:

    Code (csharp):
    1.  
    2. [JsonProperty(PropertyName="first_name")]
    3. public string FirstName {get; set;}
    4.  
    That will make the FirstName property both serialize and deserialize as "first_name"
     
  19. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,944
    thanks, is there any other way to lets say AUTP_HANDLE_UNDERSCORE like ignore null? so if i have a lot of properties using _ then it automatically remove underscore and dserialize them
     
  20. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Not really, not without writing a custom converter for each class. Better to use the JsonProperty attribute.
     
    jGate99 likes this.
  21. fadhilnoerafif

    fadhilnoerafif

    Joined:
    Nov 8, 2016
    Posts:
    5
    Hi,

    I used your plugins for our game since it was in "source code" form.
    Recently, I updated your plugins and I noticed that it is now delivered in DLLs.

    However, the app returns some AOT compilation errors when trying to deserialize some JSON :

    Code (CSharp):
    1. ExecutionEngineException: Attempting to call method 'System.Collections.Generic.List`1[[System.Single, mscorlib, Version=2.0.0.0, Culture=, PublicKeyToken=b77a5c561934e089]]::.cctor' for which no ahead of time (AOT) code was generated.
    2.   at Newtonsoft.Json.Utilities.LateBoundReflectionDelegateFactory+<>c__DisplayClass5_0`1[T].<CreateDefaultConstructor>b__1 () [0x00000] in <filename unknown>:0
    3.   at Newtonsoft.Json.Serialization.JsonArrayContract.CreateTemporaryCollection ()
    I am suspecting that this may raise when trying to Deserialize some string to DateTime, but I'm not totally sure.

    ExecutionEngineException: Attempting to call method 'System.Collections.Generic.List`1[[System.Single, mscorlib, Version=2.0.0.0, Culture=, PublicKeyToken=b77a5c561934e089]]::.cctor' for which no ahead of time (AOT) code was generated.
    at Newtonsoft.Json.Utilities.LateBoundReflectionDelegateFactory+<>c__DisplayClass5_0`1[T].<CreateDefaultConstructor>b__1 () [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonArrayContract.CreateTemporaryCollection () [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewList (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Boolean& createdFromNonDefaultCreator) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.Object existingValue, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0
    at Bedivere.IOManager+<RetrievePlayVariables>c__AnonStorey62.<>m__65 (System.String json) [0x00000] in <filename unknown>:0
    at UniRx.Operators.FromCoroutineObservable`1+FromCoroutine[T].OnNext (.T value) [0x00000] in <filename unknown>:0
    at UniRx.ObservableWWW+<FetchText>c__Iterator1.MoveNext () [0x00000] in <filename unknown>:0
    Rethrow as TypeInitializationException: The type initializer for 'System.Collections.Generic.List<System.Single>' threw an exception.
    at Newtonsoft.Json.Utilities.LateBoundReflectionDelegateFactory+<>c__DisplayClass5_0`1[T].<CreateDefaultConstructor>b__1 () [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonArrayContract.CreateTemporaryCollection () [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewList (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Boolean& createdFromNonDefaultCreator) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.Object existingValue, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0
    at Bedivere.IOManager+<RetrievePlayVariables>c__AnonStorey62.<>m__65 (System.String json) [0x00000] in <filename unknown>:0
    at UniRx.Operators.FromCoroutineObservable`1+FromCoroutine[T].OnNext (.T value) [0x00000] in <filename unknown>:0
    at UniRx.ObservableWWW+<FetchText>c__Iterator1.MoveNext () [0x00000] in <filename unknown>:0
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    at Newtonsoft.Json.Utilities.LateBoundReflectionDelegateFactory+<>c__DisplayClass5_0`1[T].<CreateDefaultConstructor>b__1 () [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonArrayContract.CreateTemporaryCollection () [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewList (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Boolean& createdFromNonDefaultCreator) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.Object existingValue, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0
    at Bedivere.IOManager+<RetrievePlayVariables>c__AnonStorey62.<>m__65 (System.String json) [0x00000] in <filename unknown>:0
    at UniRx.Operators.FromCoroutineObservable`1+FromCoroutine[T].OnNext (.T value) [0x00000] in <filename unknown>:0
    at UniRx.ObservableWWW+<FetchText>c__Iterator1.MoveNext () [0x00000] in <filename unknown>:0

    (Filename: currently not available on il2cpp Line: -1)

    Do you have some insight for this? Thanks!
     
  22. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Hooray for stripping! Yes, it looks like Unity is stripping the default constructor off of something. Most likely it's the collection itself. Btw, the source is still included in a zip file.

    OK, so take a look in my Jsondotnet folder, there should be a link.xml file (might be in /assemblies). There is a commented out line that shows how to add an entire namespace to prevent stripping. Uncomment that line and change the namespace to System.Collections.Generic and give that a try. If that doesn't fix it, we'll go a step further until we figure out what's being stripped.
     
  23. fadhilnoerafif

    fadhilnoerafif

    Joined:
    Nov 8, 2016
    Posts:
    5
    Hi Dustin-Horne,

    I tried to added the namespace in link.xml file as you said, but it still throws similar errors :

    ExecutionEngineException: Attempting to call method 'System.Collections.Generic.List`1[[System.Single, mscorlib, Version=2.0.0.0, Culture=, PublicKeyToken=b77a5c561934e089]]::.cctor' for which no ahead of time (AOT) code was generated.
    at Newtonsoft.Json.Utilities.LateBoundReflectionDelegateFactory+<>c__DisplayClass5_0`1[T].<CreateDefaultConstructor>b__1 () [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonArrayContract.CreateTemporaryCollection () [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewList (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Boolean& createdFromNonDefaultCreator) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.Object existingValue, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0
    at Bedivere.IOManager+<RetrievePlayVariables>c__AnonStorey62.<>m__65 (System.String json) [0x00000] in <filename unknown>:0
    at UniRx.Operators.FromCoroutineObservable`1+FromCoroutine[T].OnNext (.T value) [0x00000] in <filename unknown>:0
    at UniRx.ObservableWWW+<FetchText>c__Iterator1.MoveNext () [0x00000] in <filename unknown>:0
    at UniRx.InternalUtil.ThreadSafeQueueWorker.ExecuteAll (System.Action`1 unhandledExceptionCallback) [0x00000] in <filename unknown>:0
    at UniRx.MainThreadDispatcher.Update () [0x00000] in <filename unknown>:0
    Rethrow as TypeInitializationException: The type initializer for 'System.Collections.Generic.List<System.Single>' threw an exception.
    at Newtonsoft.Json.Utilities.LateBoundReflectionDelegateFactory+<>c__DisplayClass5_0`1[T].<CreateDefaultConstructor>b__1 () [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonArrayContract.CreateTemporaryCollection () [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewList (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Boolean& createdFromNonDefaultCreator) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.Object existingValue, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0
    at Bedivere.IOManager+<RetrievePlayVariables>c__AnonStorey62.<>m__65 (System.String json) [0x00000] in <filename unknown>:0
    at UniRx.Operators.FromCoroutineObservable`1+FromCoroutine[T].OnNext (.T value) [0x00000] in <filename unknown>:0
    at UniRx.ObservableWWW+<FetchText>c__Iterator1.MoveNext () [0x00000] in <filename unknown>:0
    at UniRx.InternalUtil.ThreadSafeQueueWorker.ExecuteAll (System.Action`1 unhandledExceptionCallback) [0x00000] in <filename unknown>:0
    at UniRx.MainThreadDispatcher.Update () [0x00000] in <filename unknown>:0
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    at Newtonsoft.Json.Utilities.LateBoundReflectionDelegateFactory+<>c__DisplayClass5_0`1[T].<CreateDefaultConstructor>b__1 () [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonArrayContract.CreateTemporaryCollection () [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewList (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Boolean& createdFromNonDefaultCreator) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.Object existingValue, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0
    at Bedivere.IOManager+<RetrievePlayVariables>c__AnonStorey62.<>m__65 (System.String json) [0x00000] in <filename unknown>:0
    at UniRx.Operators.FromCoroutineObservable`1+FromCoroutine[T].OnNext (.T value) [0x00000] in <filename unknown>:0
    at UniRx.ObservableWWW+<FetchText>c__Iterator1.MoveNext () [0x00000] in <filename unknown>:0
    at UniRx.InternalUtil.ThreadSafeQueueWorker.ExecuteAll (System.Action`1 unhandledExceptionCallback) [0x00000] in <filename unknown>:0
    at UniRx.MainThreadDispatcher.Update () [0x00000] in <filename unknown>:0

    (Filename: currently not available on il2cpp Line: -1)

    This is the link.xml that I used :

    <linker>
    <assemblyfullname="System">
    <typefullname="System.ComponentModel.TypeConverter"preserve="all"/>
    <typefullname="System.ComponentModel.ArrayConverter"preserve="all"/>
    <typefullname="System.ComponentModel.BaseNumberConverter"preserve="all"/>
    <typefullname="System.ComponentModel.BooleanConverter"preserve="all"/>
    <typefullname="System.ComponentModel.ByteConverter"preserve="all"/>
    <typefullname="System.ComponentModel.CharConverter"preserve="all"/>
    <typefullname="System.ComponentModel.CollectionConverter"preserve="all"/>
    <typefullname="System.ComponentModel.ComponentConverter"preserve="all"/>
    <typefullname="System.ComponentModel.CultureInfoConverter"preserve="all"/>
    <typefullname="System.ComponentModel.DateTimeConverter"preserve="all"/>
    <typefullname="System.ComponentModel.DecimalConverter"preserve="all"/>
    <typefullname="System.ComponentModel.DoubleConverter"preserve="all"/>
    <typefullname="System.ComponentModel.EnumConverter"preserve="all"/>
    <typefullname="System.ComponentModel.ExpandableObjectConverter"preserve="all"/>
    <typefullname="System.ComponentModel.Int16Converter"preserve="all"/>
    <typefullname="System.ComponentModel.Int32Converter"preserve="all"/>
    <typefullname="System.ComponentModel.Int64Converter"preserve="all"/>
    <typefullname="System.ComponentModel.NullableConverter"preserve="all"/>
    <typefullname="System.ComponentModel.SByteConverter"preserve="all"/>
    <typefullname="System.ComponentModel.SingleConverter"preserve="all"/>
    <typefullname="System.ComponentModel.StringConverter"preserve="all"/>
    <typefullname="System.ComponentModel.TimeSpanConverter"preserve="all"/>
    <typefullname="System.ComponentModel.UInt16Converter"preserve="all"/>
    <typefullname="System.ComponentModel.UInt32Converter"preserve="all"/>
    <typefullname="System.ComponentModel.UInt64Converter"preserve="all"/>
    <namespacefullname="System.Collections.Generic"preserve="all"/>
    </assembly>
    </linker>

    What makes me confused is that when I was still using the source version (from older plugin version), it works, but now it doesn't.
     
  24. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Hmm, would it be possible for you to shoot me a repro via email or a link to download one? And yeah, I hear your confusion. It has something to do with the way stripping works and I don't quite understand it. Changing from source to a compiled assembly makes Unity's stripping engine behave differently and strip different stuff, but also it's a new version of JSON .NET so the DLL's are radically different than what was in the original source.

    The telling part of your error is this:

    ExecutionEngineException: Attempting to call method 'System.Collections.Generic.List`1[[System.Single, mscorlib, Version=2.0.0.0, Culture=, PublicKeyToken=b77a5c561934e089]]::.cctor' for which no ahead of time (AOT) code was generated.

    cctor is shorthand for "constructor". It's essentially saying that there's no constructor for List<single>. Most likely it's been stripped or something related has been stripped. The other possibility though, if you're using iOS, is that you need to allocate more trampolines, though I'm not sure if that impacts IL2CPP at all or whether that's specific to the old Mono backend.

    Here's another thing you can try... just for a test... Right before you call Deserialize, add this:
    Code (csharp):
    1. var junkObject = new List<single>();
    Since you've added that explicitly, it'll prevent Unity from stripping the constructor so we can see right away if that's the object type that's causing the issue or if the stack trace is misleading.
     
  25. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    304
    I'm having an issue serializing a simple list of colors in unity 5.5 with the latest version of your asset. Error is below:

    Code (CSharp):
    1. JsonSerializationException: Self referencing loop detected for property 'linear' with type 'UnityEngine.Color'. Path '[0]'.
    2. Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CheckForCircularReference (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty)
    3. Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContainerContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.Serialization.JsonContract& memberContract, System.Object& memberValue)
    4. Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty)
    5. UnityEngine.EventSystems.EventSystem:Update()
    Any ideas on what may be going on? Thanks!
     
  26. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Yep it's because the linear property returns another color and it's a calculated property. Just do this once somewhere in your initialization code:

    Code (csharp):
    1.  
    2. JsonConvert.DefaultSettings().Converters.Add(new ColorConverter());
    3.  
    The corconverter is in the Newtonsoft.Json.Converters namespace and it'll work for both Color and Color32.
     
    mons00n likes this.
  27. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    I should add, there are several converters there and only a couple of them are added by default. The reason is that there's a type check for all of those converters. For example they each have a CanConvert(Type targetType) method. The checks are pretty simple, checking if your object is a specific type or if it can convert from / to a certain type, but all of those converters in the Converters collection are checked for every object in your hierarchy that gets serialized / deserialized.

    If we by default just added all of the converters and you had large pieces of json or large deeply complex objects to serialize, then that would be a lot of type checks so by default I only enabled the critical Unity ones (VectorConverter and a couple others) and for IL2CPP the HashSetConverter is also enabled since it doesn't play nicely with IL2CPP.
     
  28. seanybaby2

    seanybaby2

    Joined:
    May 17, 2013
    Posts:
    120
    Hey Dustin,

    First off I wanted to say thanks for making this awesome plugin. Secondly I am having some trouble at the moment that I thought you could help me out with.

    I'm currently trying to deserialize an array of enums. When deseriliezing I'm getting some errors. Basically when deserializing it's telling me that it won't run -JIT and that I need to run -AOT only. I think what is happening is that the JSON deseriliazation method is converting my Array of Enums and converting them to a list before deserialization completes. Does this make sense to you? Any idea how to work around this? The deserialization is working fine on my arrays of strings, I'm thinking I may have to convert my enum arrays into string arrays.

    I'm going to share with you some of my code.


    Code (CSharp):
    1. //Deserialization
    2. public static GameData ReadGameData(string szFullPath)
    3.     {
    4.         GameData gameData = null;
    5.  
    6.             JsonSerializer serializer = new JsonSerializer();
    7.             byte[] saveBytes = GetBytes();    //These bytes were previously requested
    8.             if (saveBytes != null)
    9.             {
    10.                 Debug.LogError("Not Null, going to deserialize");
    11.                 using (MemoryStream ms = new MemoryStream(saveBytes))
    12.                 {
    13.                     using (Newtonsoft.Json.Bson.BsonReader bson = new Newtonsoft.Json.Bson.BsonReader(ms))
    14.                     {
    15.                         gameData = serializer.Deserialize<GameData>(bson);
    16.                     }
    17.                 }
    18.           }
    19.       }

    //Serializable Class
    Code (CSharp):
    1.     [Serializable]
    2.     public class GameData
    3.     {
    4.         public bool[] pageStatuses = new bool[125];
    5.         public SpearTypes spearType;
    6.         public CharacterTypes charType;
    7.         public bool eliteMode;
    8.    
    9.         // Gameplay data
    10.         public int playerKeys;
    11.         public float playerHealth;
    12.         public float playerCredits;
    13.         public float playerBounty;
    14.  
    15.  
    16.         public string[] shopItemParentNames = new String[100];
    17.         public float[] shopItemSaveLocationX = new float[100];
    18.         public float[] shopItemSaveLocationY = new float[100];
    19.         public float[] shopItemSaveLocationZ = new float[100];
    20.  
    21.         public ShipRuneType[] shopShipTypes = new ShipRuneType[100];
    22.         public SpearRuneType[] shopSpearTypes = new SpearRuneType[100];
    23.         public ConsumableType[] shopConsumableTypes = new ConsumableType[100];
    24.  
    25.  
    26. ... lots more
    EDIT: Here's the the error message that I'm getting.

    Code (CSharp):
    1.  
    2. ExecutionEngineException: Attempting to JIT compile method 'System.Collections.Generic.List`1<ShipRuneType>:.ctor ()' while running with --aot-only.
    3.  
    4.   at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod*,object,object[],System.Exception&)
    5.   at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    6. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    7.   at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    8.   at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    9.   at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0
    10.   at Newtonsoft.Json.Utilities.LateBoundReflectionDelegateFactory+<>c__DisplayClass5_0`1[System.Object].<CreateDefaultConstructor>b__1 () [0x00000] in <filename unknown>:0
    11.   at Newtonsoft.Json.Serialization.JsonArrayContract.CreateTemporaryCollection () [0x00000] in <filename unknown>:0
    12.   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewList (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, System.Boolean& createdFromNonDefaultCreator) [0x00000] in <filename unknown>:0
    13.   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.Object existingValue, System.String id) [0x00000] in <filename unknown>:0
    14.   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0
    15.   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <filename unknown>:0
    16.   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <filename unknown>:0
    17. .
     
  29. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    It's a pretty classic exception that I unfortunately see fairly frequently. This is caused by Unity stripping. In this particular instance it's a contstructor for List<ShipRuneType>. The list is used internally to process json arrays. It doesn't actualy convert "to" a list, it deserializes each element into a list and then returns an array.

    Let's try something real quick... Before you deserialize let's just throw this line of code in:

    Code (csharp):
    1.  
    2. var throwaway = new List<ShipRuneType>();
    3.  
    See if the error goes away. If it does, then we know it's a stripping issue and just need to add some entries to your link.xml file to prevent those specific types from being stripped.
     
  30. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    298
    Hiya!

    I've just purchased this asset, it is really, really nice! However I can't seem to enable saving enums as their name/string value. The documentation says to use a converter, so I have created a settings object with a new StringEnumConverter() and pass it to my serialization, but it is still using the default method. I've also searched for the DefaultEnumSerializationHandling setting, however it doesn't appear to exist anymore.

    Apologies if this is stupidity on my part!

    Edit: I figured out that I wasn't using the [JsonConverter(typeof(StringEnumConverter))] attribute! My apologies! (It also looks like you don't need to have a settings object if you use these attributes?)

    Edit 2: Ok, another question! I suspect I already know the answer, but is it possible to have a header in file, so the correct loading type can be determined? e.g. A smaller part of the file that simply has a 'version' key?

    Edit 3: Another question, though I hope this is the last, hehe. I'm trying to serialize a Vector2, and when I save I am getting this error:

    Code (CSharp):
    1. JsonSerializationException: Self referencing loop detected for property 'normalized' with type 'UnityEngine.Vector2'. Path 'currentPosition.normalized'.
    However it still saves the file.
     
    Last edited: Jan 15, 2017
  31. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    @gumboots Hmm... you shouldn't have to use the attribute if you use the converter.
    Code (csharp):
    1.  
    2. JsonConvert.DefaultSettings().Converters.Add(new StringEnumConverter());
    3.  
    If you add the above line it should serialize all enums to their string values. As to your second issue, my guess here is that you've cleared the converters on the default settings. If you do that you'll lose the converters that are added by default like the VectorConverter which handles Vector2, Vector3 and Vector4. That's why you're getting the self referencing loop issue. With that converter, it won't even try to serialize that property, but I'll double check it to make sure it's still working properly for Vector2.
     
  32. gumboots

    gumboots

    Joined:
    May 24, 2011
    Posts:
    298
    Hmm.. I haven't cleared any of the default settings. The only time I touch JsonConvert.DefaultSettings() is to adjust DefaultValueHandling. I'm trying to save the same data as two different files, one as JSON and one as BSON, perhaps that's relevant? Here's the code (it's only a rough implementation to test out the asset)

    Code (CSharp):
    1. if(saveDefaultValues) {
    2.     JsonConvert.DefaultSettings().DefaultValueHandling = DefaultValueHandling.Include;
    3. } else {
    4.     JsonConvert.DefaultSettings().DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate;
    5. }
    6.  
    7. SaveGameData save = new SaveGameData();
    8. save.screenshot = GetScreenShot();
    9. string jsonString = JsonConvert.SerializeObject(save, Formatting.Indented);
    10. string filePath = Path.Combine(Application.persistentDataPath, "save.sv");
    11. File.WriteAllText(filePath, jsonString);
    12.  
    13. filePath = Path.Combine(Application.persistentDataPath, "save-binary.svb");
    14. using (var fs = File.Open(filePath, FileMode.Create)) {
    15.     using (var writer = new BsonWriter(fs)) {
    16.         var serializer = new JsonSerializer();
    17.         serializer.Serialize(writer, save);
    18.     }
    19. }
    The error comes up on the binary save, the JSON save saves without error.

    Also I tried out your suggestion for editing the default setting for converters and it worked. But I think I might keep using the attribute as I don't necessarily want all enums saved as their name values.
     
    Dustin-Horne likes this.
  33. seanybaby2

    seanybaby2

    Joined:
    May 17, 2013
    Posts:
    120

    Thanks for the help Dustin! I actually converted my enums to strings using System functions. I probably should of waited for your response instead but everything works great now.
     
    Dustin-Horne likes this.
  34. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    I'll have to double check how BSON uses the converters... it's possible the converters aren't being utilized. One thing you can do is change the ReferenceLoopHandling property on DefaultSettings (or create a cache a specific settings object, the VectorConverter is added by default). Set it to Ignore which will cause those auto generated properties (and any reference loops) to not be serialized:

    Code (csharp):
    1.  
    2. JsonConvert.DefaultSettings().ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
    3.  
     
    OmarVector and Danilo_Sozap like this.
  35. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Would this serialize and deserialize a rect[] perfectly fine?
     
  36. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Looking at the definition for Rect, it looks like it as a property called .zero which returns a Rect. That would create the same issue as VectorX.normalized so it would need a custom converter as I haven't written one for it yet, but it would be very easy to do, and then yes it would serialize and deserialize the array just fine.
     
  37. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Could you do one for it some time please?
     
  38. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Sure, I won't be able to get to it today.
     
  39. jonmarxent

    jonmarxent

    Joined:
    Jan 25, 2017
    Posts:
    7
    Hi, i've seen a couple references to this error on this thread, but havent been able to follow the thread through to a resolution on the issue. I am on Unity version 5.4.3, using JSON .Net version 9.0.1. Runs fine in the unity editor, but when i do a webGL build i get:

    Unsupported internal call for IL2CPP:DynamicMethod::create_dynamic_method - System.Reflection.Emit is not supported.

    What is the workaround for this?
     
  40. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    You're using the official release of Json .NET, not my asset. The official release won't work with any IL2CPP platforms, WebGL, etc. It uses Reflection.Emit to generate and emit dynamic IL which isn't supported on AOT platforms.
     
  41. jonmarxent

    jonmarxent

    Joined:
    Jan 25, 2017
    Posts:
    7
    Thank you! I will use the asset instead... two quick questions:
    1) do you know what the max serialization/deserialization depth is that the asset supports? Is it the same as the official release?
    2) Does the asset support the same features as the official release? In particular, custom converters?
     
  42. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Yes to both questions. This is the official release, but modified to support Unity across multiple in a number of ways. The asset is based on Json .NET 8.x. I could update to 9.x but there are some customers that are using it with libraries that have hard dependencies on 8.x versioning and I'm not aware of any compelling changes that would warrant moving to 9.x at the moment.

    In fact, in the asset if you unzip the source and look in the /Newtonsoft.Json/Converters folder you'll see that I've added several custom converters to support various Unity types with more coming.
     
  43. jonmarxent

    jonmarxent

    Joined:
    Jan 25, 2017
    Posts:
    7
    Thanks! Might be useful for folks like me if somewhere on http://www.newtonsoft.com/json (maybe under the section where it says "World-class JSON Serializer, LINQ To JSON, etc") it stated that it offers Unity Support with a link to the unity asset. Thanks for your very prompt replies.
     
  44. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Thanks! I'm not in any way affiliated with James Newton-King or the official version so it's highly unlikely that he'd have any interest in linking to my asset, but thanks for the thought. :)
     
  45. vivalavida

    vivalavida

    Joined:
    Feb 26, 2014
    Posts:
    85
    Hi @Dustin-Horne ,

    This is Xbox One related,

    This is the error I'm getting the the Debug output:
    ExecutionEngineException: Attempting to JIT compile method 'System.Reflection.MonoProperty:GetterAdapterFrame<LevelStarModel, bool> (System.Reflection.MonoProperty/Getter`2<LevelStarModel, bool>,object)' while running with --aot-only.

    at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Utilities.ReflectionUtils.GetMemberValue (System.Reflection.MemberInfo member, System.Object target) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.ReflectionValueProvider.GetValue (System.Object target) [0x00000] in <filename unknown>:0
    Rethrow as JsonSerializationException: Error getting value from 'isLevelComplete' on 'LevelStarModel'.
    at Newtonsoft.Json.Serialization.ReflectionValueProvider.GetValue (System.Object target) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContainerContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.Serialization.JsonContract& memberContract, System.Object& memberValue) [0x00000] in <filename unknown>:0
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x00000] in <filename unknown>:0

    And this is the code that is handling the Serialization:
    Code (CSharp):
    1.  
    2.  
    3.  
    4. void InitializeStarDataList()
    5.     {
    6.         LevelStarData = new List<LevelStarModel>();
    7.         for (int i = 0; i < NumberOfLevels; i++)
    8.         {
    9.          
    10.             LevelStarData.Add(new LevelStarModel { isLevelComplete = false, isTimeBeaten = false, isItemCollected = false, isTimeAndItemTogether = false });
    11.         }
    12.    
    13.     }
    14.  
    15. public void JsonSaveGameHealthAndScore()
    16.     {
    17. myHealthAndScoringSystemDataSerialized = new HealthAndScoringSystemData
    18.         {
    19.             myCurrentHealth = currentHealth,
    20.             myMaxCurrentHealth = maxCurrentHealth,
    21.  
    22.             myCurrentRateOfHealthIncrease = currentRateOfHealthIncrease,
    23.             myCurrentRateOfHealthDrop = currentRateOfHealthDrop,
    24.  
    25.             myCurrentDamagePower = currentDamagePower,
    26.  
    27.             myCurrentCoinCount = currentCoinCount,
    28.  
    29.             myCurrentRateOfCoinIncrease = currentRateOfCoinIncrease,
    30.  
    31.             myCoinToBottleThreshold = coinToBottleThreshold,
    32.  
    33.             myCurrentBottleCount = currentBottleCount,
    34.  
    35.             myGlobalCoinCount = globalCoinCount,
    36.  
    37.             myGlobalCollectedHeartCount = globalCollectedHeartCount,
    38.  
    39.             myGlobalBottleCount = globalBottleCount,
    40.  
    41.             myMaxCurrentBottleSlots = maxCurrentBottleSlots,
    42.  
    43.             myCurrentRemainingBullets = currentRemainingBullets,
    44.             myMaxCurrentBullets = maxCurrentBullets,
    45.  
    46.             myCurrentDamageBySmallBullets = currentDamageBySmallBullets,
    47.             myCurrentDamageByBigBullets = currentDamageByBigBullets,
    48.             myCurrentLifeTimeSmallBullets = currentLifeTimeSmallBullets,
    49.             myCurrentLifeTimeBigBullets = currentLifeTimeBigBullets,
    50.  
    51.  
    52.             //world1
    53.             myWorld1Gate1 = World1Gate1,
    54.             myWorld1Gate2 = World1Gate2,
    55.             myWorld1Gate3 = World1Gate3,
    56.             myWorld1Gate4 = World1Gate4,
    57.             //world2
    58.             myWorld2Gate1 = World2Gate1,
    59.             myWorld2Gate2 = World2Gate2,
    60.             myWorld2Gate3 = World2Gate3,
    61.             myWorld2Gate4 = World2Gate4,
    62.             //world3
    63.             myWorld3Gate1 = World3Gate1,
    64.             myWorld3Gate2 = World3Gate2,
    65.             myWorld3Gate3 = World3Gate3,
    66.             myWorld3Gate4 = World3Gate4,
    67.             //world4
    68.             myWorld4Gate1 = World4Gate1,
    69.             myWorld4Gate2 = World4Gate2,
    70.             myWorld4Gate3 = World4Gate3,
    71.             myWorld4Gate4 = World4Gate4,
    72.             //world5
    73.             myWorld5Gate1 = World5Gate1,
    74.             myWorld5Gate2 = World5Gate2,
    75.             myWorld5Gate3 = World5Gate3,
    76.             myWorld5Gate4 = World5Gate4,
    77.  
    78.  
    79.             myWorld1Zone1KeyCount = World1Zone1KeyCount,
    80.             myWorld1Zone2KeyCount = World1Zone2KeyCount,
    81.             myWorld1Zone3KeyCount = World1Zone3KeyCount,
    82.             myWorld1Zone4KeyCount = World1Zone4KeyCount,
    83.  
    84.             myWorld2Zone1KeyCount = World2Zone1KeyCount,
    85.             myWorld2Zone2KeyCount = World2Zone2KeyCount,
    86.             myWorld2Zone3KeyCount = World2Zone3KeyCount,
    87.             myWorld2Zone4KeyCount = World2Zone4KeyCount,
    88.  
    89.             myWorld3Zone1KeyCount = World3Zone1KeyCount,
    90.             myWorld3Zone2KeyCount = World3Zone2KeyCount,
    91.             myWorld3Zone3KeyCount = World3Zone3KeyCount,
    92.             myWorld3Zone4KeyCount = World3Zone4KeyCount,
    93.  
    94.             myWorld4Zone1KeyCount = World4Zone1KeyCount,
    95.             myWorld4Zone2KeyCount = World4Zone2KeyCount,
    96.             myWorld4Zone3KeyCount = World4Zone3KeyCount,
    97.             myWorld4Zone4KeyCount = World4Zone4KeyCount,
    98.  
    99.             myWorld5Zone1KeyCount = World5Zone1KeyCount,
    100.             myWorld5Zone2KeyCount = World5Zone2KeyCount,
    101.             myWorld5Zone3KeyCount = World5Zone3KeyCount,
    102.             myWorld5Zone4KeyCount = World5Zone4KeyCount,
    103.  
    104.             myLastLevelPlayed =  Application.loadedLevelName,
    105.             myLevelStarData = LevelStarData
    106.  
    107.         };
    108.  
    109.  
    110. using (mySavableMemoryStream = new MemoryStream())
    111.         {
    112.             using (BsonWriter writer = new BsonWriter(mySavableMemoryStream))
    113.             {
    114.  
    115.                 JsonSerializer serializer = new JsonSerializer();
    116.  
    117.                 serializer.Serialize(writer, myHealthAndScoringSystemDataSerialized);
    118.                 Debug.LogError("Player health and score Serialized");
    119.  
    120.             }
    121.         }
    122.  
    123.         serializedDataByteArray = mySavableMemoryStream.ToArray();
    124. }

    This debug message doesn't show up. so I guess there is an error at this stage.
    Code (CSharp):
    1. Debug.LogError("Player health and score Serialized");

    and my class LevelStarModel is
    Code (CSharp):
    1. public class LevelStarModel
    2. {
    3.     public bool isLevelComplete { get; set; }
    4.     public bool isTimeBeaten { get; set; }
    5.     public bool isItemCollected { get; set; }
    6.     public bool isTimeAndItemTogether { get; set; }
    7. }
    I'm getting back to the Xbox port after over a year, and as far as I recall, things worked the last time.

    Everything works fine on the PC Build

    I've recently updated to the latest version of JSON.NET For Unity

    Thanks in advance
     
    Last edited: Feb 1, 2017
  46. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Can you send me a PM with your email address or better yet, Skype? I'd like to take a deeper look at this. I've seen issues specifically with "bool" on Xbox One in the past, but they were generally related to using a JObject and Unity had some weird error where it was thinking it was a "byte" internally. This might be related so I'd like to dig into it a bit.
     
  47. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166
    @Dustin-Horne I do have JSON.Net for Unity. I also want to use it for our game server that uses C# .Net (not Unity). Which files do I need to import to do that?

    The server is on Windows OS, so do I just import Newtonsoft.Json.dll from the Assemblies/Windows/ directory?
     
  48. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    That assembly is for UWP. If this is a .NET application and not using anything Unity specific, just use the official Newtonsoft.Json release from Nuget. If your server imports Unity specific stuff (references UnityEngine.dll), then you can use the version that's in the /Assemblies/Standalone folder, or you can use the official release from Nuget since it's a standalone .NET application, but if you use the official one you'll still need to open the zipped source from my asset, copy the converters from the Newtonsoft.Json/Converters folder and compile those into an assembly to reference so you can handle types like Vectors, Color / Color32, Matrix4x4, etc.
     
  49. Waz

    Waz

    Joined:
    May 1, 2010
    Posts:
    287
    This looks good, but the documentation of what it can and cannot do seems extremely sparse. The product page basically just says "buy here" and gives an example that's just a simple case that JSON.NET already supports. Is this just for iOS development, or does it actually provide useful converters and ways to serialize MonoBehaviour (even if ignoring deprecated .rigidbody, transform, etc.)?
     
  50. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    I probably should enhance that a bit but it doesn't get much traffic so I haven't worried about it. There is a ton of great documentation on the official site:
    http://www.newtonsoft.com/json/help/html/Introduction.htm

    As for platforms it supports just about everything. As of v 2.0 I no longer support Web Player or Windows 8. But it does support iOS, Android, PC, Mac, Linux, Xbox 360, PS3, PS4, Xbox One, UWP (Windows 10, Xbox, HoloLens, etc), WebGL, etc. It supports AppleTV, Tizen, just about all Unity platforms.

    It also comes with a bunch of built in converters to handle Vectors, Color, Color32, Matrix4x4, Resolution and make HashSet serializeable on AOT platforms (like IL2CPP).

    It doesn't natively support MonoBehaviour classes. There are several properties (now deprecated but still existing) that it tries to serialize, but Unity throws custom exceptions. Because Unity overrides the == operator, in C# it looks like those properties are null but when JSON .NET inspects them via reflection, it sees a value and tries to serialize, at which point Unity throws their own custom exception for trying to access properties that aren't initialized.

    It is possible to serialize MonoBehaviours by writing custom converters but built in support isn't added because the utility in most cases is limited. There's no real way to deserialize them and retain all of the proper references, transforms, etc since you can't just say: new SomeGameObject();.