Giter VIP home page Giter VIP logo

json.net.unity3d's Introduction

Build status

Newtonsoft Json.NET for Unity3D

Newtonsoft Json.NET is a de facto standard JSON library in .NET ecosystem. But it doesn't support Unity3D, so it's a little bit hard to use JSON.NET just after getting Json.NET package. This package is for Unity3D programmers that need to use latest Json.NET in Unity3D.

Where can I get it?

Visit Release page to get latest Json.NET unity-package.

To use this library in IL2CPP build settings, you need to add link.xml to your project's asset folder. For detailed information about link.xml, read unity manual about this.

What's the deal?

Unity3D has old-fashioned and bizarre .NET Framework like these :)

  • Basically based on .NET Framework 3.5 (forked Mono 2.6)
  • Runtime lacks some types in .NET Framework 3.5 (like System.ComponentModel.AddingNewEventHandler)
  • For iOS, dynamic code emission is forbidden by Apple AppStore.

Because Newtonsoft Json.NET doesn't handle these limitations, errors will welcome you when you use official Json.NET dll targetting .NET 3.5 Framework.

What's done?

Following works are done to make Json.NET support Unity3D.

  • Based on Newtonsoft Json.NET 9.
  • Disable IL generation to work well under AOT environment like iOS.
  • Remove code related with System.ComponentModel.
  • Remove System.Data and EntityKey support.
  • Remove XML support.
  • Remove DiagnosticsTraceWriter support.
  • Workaround for differences between Microsoft.NET & Unity3D-Mono.NET

For Unity.Lite version, additional works are done to make more lite.

  • Remove JsonLinq, JPath (JToken, ...)
  • Remove Bson

Unit Test

Tests in Json.NET are updated to be able to run under UnityEditor Test Runner. All tests pass under Microsoft .NET 3.5 but with UnityEditor some of them fail because there are not-implemented features and bugs in Unity3D-Mono framework.

Test Result:

Profile ✅ Passed ❌ Failed ⚪ Ignored
Microsoft.NET 1605 0 1
Unity3D-Mono 1592 13 1

Detailed Description is here to tell you what failed and why.

Unity Compatibility

This library is tested on Unity 4.7, 5.2 and 5.3. For AOT environment like iOS, you need to use IL2CPP instead of obsolute Mono-AOT because IL2CPP handles generic code better than Mono-AOT. With Mono-AOT configuration, AOT related exception would be thrown.

For windows store build, there is a compatibility issue related with UWP. If you have a problem, please read workaround for UWP.

FAQ

Q: MissingMethodException is thrown for ComponentModel.TypeConverter.

MissingMethodException: Method not found:
Default constructor not found...ctor() of System.ComponentModel.TypeConverter.

Make sure that link.xml is added to your project.

Q: ExecutionEngineException is thrown in calling CreateValueInternal.

xecutionEngineException:
  Attempting to call method 'CLASS::.cctor' for which no ahead of time (AOT) code was generated.
at System.Reflection.MonoCMethod.Invoke (...)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal

This exception is thrown because Unity3D strips out unnecessary classes which are actually used by serialization. To fix this problem, just put new CLASS() in your code to prevent Unity3D from removing the class.

Reference: TroubleShootingIPhone

Q: ArgumentNullException is thrown in calling CreateParameterizedConstructor.

ArgumentNullException: Argument cannot be null.
Parameter name: method
at Newtonsoft.Json.Utilities.ValidationUtils.ArgumentNotNull (...)
at Newtonsoft.Json.Utilities.LateBoundReflectionDelegateFactory.CreateParameterizedConstructor (...)

This is similar with the previous case. But this case is tricky because this is caused by Json.NET internal classes such as CollectionWrapper<T>. To fix this problem, put AotHelper.EnsureList<T>() if you use HashSet<T> or AotHelper.EnsureDictionary<TKey, TValue>() if you use Dictionary<TKey, TValue> in working class.

json.net.unity3d's People

Contributors

veblush avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

json.net.unity3d's Issues

Failed to resolve base type System.Tuple2<T1,T2>

WEB_GL build in unity, using the Lite version:

stdout:
ERROR: Failed to resolve base type System.Tuple2<T1,T2> for type System.Xaml.Schema.ReferenceEqualityTuple2
Fatal error in Mono CIL Linker
System.Exception: ERROR: Failed to resolve base type System.Tuple2<T1,T2> for type System.Xaml.Schema.ReferenceEqualityTuple2
at UnusedBytecodeStripper2.ResolveFromMonoBehaviours.IsMonoBehaviourOrScriptableObject(TypeDefinition type)
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at UnusedBytecodeStripper2.ResolveFromMonoBehaviours.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at Mono.Linker.Driver.RunDriver(Driver driver)
stderr:

Circular reference when serializing Vectors

When serializing a Unity vector such as Vector2 or Vector3, there is a circular reference on the normalized field.

This is not an issue in this other Json.Net implementation from the Unity store: https://assetstore.unity.com/packages/tools/input-management/json-net-for-unity-11347

I was hoping to be able to upgrade since that one has been unsupported for a long time and uses an old version of Json.Net, however this is a deal breaker. I'm not 100% sure what they did to make Vectors work, but the source code is available in that package. Probably the normalized field just needs to be explicitly omitted.

Getting Unable to find a constructor error in WebGL

I'm trying to De-serialize JSON string I'm getting from a web-service.
When I run the code in the Unity editor everything works fine, but when I make a WebGL build and I run it on a browser I'm getting this error.

Unable to find a constructor to use for type {0}. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute.

I found it in the CreateNewObject method inside the JsonSerializerInternalReader class.
I tried adding the [JsonConstructor] decorator to an empty/default constructor of my classes, but nothing changes.

Could not load assembly 'Assembly-CSharp, Version=0.1.6240.32398' on Android

This has been working great for me in editor, but on an Android device I got the following error:
JsonSerializationException: Could not load assembly 'Assembly-CSharp, Version=0.1.6240.32398'

Is there something I need to do to get the dll to work on Android? My API compatibility level is set to .NET 2.0 and this is in Unity 5.4 building for Android 7.

ios Issue on deserialization of System.Nullable<long>[]

Source/destination types

public class NullableTest {
	private System.Nullable<long>[] idsField;
	public System.Nullable<long>[] ids
	{
		get
		{
			return this.idsField;
		}
		set
		{
			this.idsField = value;
		}
	}
}

Source/destination JSON

{"ids":[15968,15962,15963,15964,15965,15966,15967]}


### Expected behavior

Deserialize in all available platform

### Actual behavior

on ios platform (with mscorlib cpp usage), android platform works perfectly

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ExecutionEngineException: Attempting to call method 'System.Collections.Generic.List`1[[System.Nullable`1[[System.Int64, mscorlib, Version=2.0.0.0, Culture=, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=2.0.0.0, Culture=, PublicKeyToken=b77a5c561934e089]]::.ctor' for which no ahead of time (AOT) code was generated.
  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 
  at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0 
  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.PopulateList (IList list, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id) [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.Populate (Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.JsonSerializer.PopulateInternal (Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.JsonConvert.PopulateObject (System.String value, System.Object target, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.JsonConvert.PopulateObject (System.String value, System.Object target) [0x00000] in <filename unknown>:0 

Steps to reproduce

JsonConvert.Deserialize<T>(jsonText);
or
JsonConvert.PopulateObject(jsonText,new NullableText());

used on a c# ios Unity project using always il2cpp

JPath not removed?

In the description, where you describe what's been done, is stated that JPath has been removed:

Remove JPath class to reduce size of DLL.

However, when I look in the repo (\src\Newtonsoft.Json\Linq\JsonPath), JPath.cs and everything for jpath is still there.

Am I looking at this wrong?

Value is greater than UInt16.MaxValue or less than UInt16.MinValue

OverflowException: Value is greater than UInt16.MaxValue or less than UInt16.MinValue
System.Convert.ToUInt16 (Int64 value) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Convert.cs:2070)
System.Int64.System.IConvertible.ToUInt16 (IFormatProvider provider) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Int64.cs:600)
System.Convert.ToType (System.Object value, System.Type conversionType, IFormatProvider provider, Boolean try_target_to_type) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Convert.cs:2907)
System.Convert.ChangeType (System.Object value, System.Type conversionType, IFormatProvider provider) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Convert.cs:2511)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType (Newtonsoft.Json.JsonReader reader, System.Object value, System.Globalization.CultureInfo culture, Newtonsoft.Json.Serialization.JsonContract contract, System.Type targetType) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:997)

hello, i found this error, maybe jsonstr is too long?

Deserialize struct (Editor & iOS)

On .Net and the standard Newtonsoft JSON nuget structs can be parsed implementing the Parse method.

https://gist.github.com/t0chas/af5bc562d3fe411af4e2f1aced153301

I am getting an ArgumentException

ArgumentException: Could not cast or convert from System.String to SmallFactories.Model.ProductItems. Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable (System.Object value, System.Type initialType, System.Type targetType) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Utilities/ConvertUtils.cs:668) Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast (System.Object initialValue, System.Globalization.CultureInfo culture, System.Type targetType) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Utilities/ConvertUtils.cs:639) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType (Newtonsoft.Json.JsonReader reader, System.Object value, System.Globalization.CultureInfo culture, Newtonsoft.Json.Serialization.JsonContract contract, System.Type targetType) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:1000) Rethrow as JsonSerializationException: Error converting value "SmallCirclex4" to type 'SmallFactories.Model.ProductItems'. Path 'Recipes[0].Inputs[0]', line 1, position 408. Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType (Newtonsoft.Json.JsonReader reader, System.Object value, System.Globalization.CultureInfo culture, Newtonsoft.Json.Serialization.JsonContract contract, System.Type targetType) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:1004) 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) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:317) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList (IList list, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:1644) UnityEngine.Debug:LogException(Exception) HttpRestClient:thread_worker(Object) (at Assets/RestClient/HttpRestClient.cs:173)

Any thoughts? Thanks

JObject ?

Hello.

I would like to know if we can use JObject with your package ?

Visual Studio can't find the type
image

and there is nothing under Newtonsoft.Json.Linq

image

I want to achieve something like that :

image

One step missing in the UWP workaround

First of all, great project. Saves me a lot of time. Thanks.

The Newtonsoft.Json.dll directly under Assets/UnityPackages/JsonNet should have all platforms except WSAPlayer checked. Otherwise the example scripts you provided will not compile because there are 2 dlls linked.

Unity 2017.1.2f1: Could not load assembly 'UnityEngine.CoreModule'

We upgraded from Unity 5.6 to Unity 2017 and are now getting the following crash:

JsonSerializationException: Could not load assembly 'UnityEngine.CoreModule'.
Newtonsoft.Json.Serialization.DefaultSerializationBinder.GetTypeFromTypeNameKey (TypeNameKey typeNameKey) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/DefaultSerializationBinder.cs:82)
Newtonsoft.Json.Utilities.ThreadSafeStore2[Newtonsoft.Json.Serialization.DefaultSerializationBinder+TypeNameKey,System.Type].AddValue (TypeNameKey key) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Utilities/ThreadSafeStore.cs:66) Newtonsoft.Json.Utilities.ThreadSafeStore2[Newtonsoft.Json.Serialization.DefaultSerializationBinder+TypeNameKey,System.Type].Get (TypeNameKey key) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Utilities/ThreadSafeStore.cs:58)
Newtonsoft.Json.Serialization.DefaultSerializationBinder.BindToType (System.String assemblyName, System.String typeName) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/DefaultSerializationBinder.cs:142)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolveTypeName (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.String qualifiedTypeName) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:802)
Rethrow as JsonSerializationException: Error resolving type specified in JSON 'UnityEngine.Vector3, UnityEngine.CoreModule'. Path 'args.$values[1].CasterHotspotLocation.$type', line 1, position 690.
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolveTypeName (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.String qualifiedTypeName) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:806)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadMetadataProperties (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, System.Object& newValue, System.String& id) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:752)
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) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:459)
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) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:293)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolvePropertyAndCreatorValues (Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Type objectType) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:2177)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObjectUsingCreatorWithParameters (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.Serialization.ObjectConstructor`1 creator, System.String id) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:1920)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract objectContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id, System.Boolean& createdFromNonDefaultCreator) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:2296)
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) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:488)
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) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:293)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:167)

Don't support UWP project

I have tried your unity dll library, and it works perfect on PC. But it failed when I try build my unity project to UWP project. The errors look like this:

default

Deserialization error in XCode for iOS build: MissingMethodException

I am using Unity version 2017.2.0f3 with Newtonsoft.Json

I am trying to deserialize in an iOS build. The error happens in the Deserialize call here:

	JsonSerializer serializer = new JsonSerializer();
	serializer.Converters.Add(new ConditionalConverter());
	serializer.Converters.Add(new StringEnumConverter());
	serializer.Converters.Add(new VariableConverter());

    using (var jsonReader = new JsonTextReader(new StringReader(jsonFile.text)))
	{
		myStory = serializer.Deserialize<Story>(jsonReader);
	}

This code works fine when I run it inside Unity. However when I make an iOS build and run that build in XCode, I get the following error:

MissingMethodException: Constructor on type 'System.ComponentModel.ReferenceConverter' not found.
at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00000] in <00000000000000000000000000000000>:0
at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture) [0x00000] in <00000000000000000000000000000000>:0
at System.SecurityUtils.SecureCreateInstance (System.Type type, System.Object[] args, System.Boolean allowNonPublic) [0x00000] in <00000000000000000000000000000000>:0
at System.SecurityUtils.SecureCreateInstance (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
at System.ComponentModel.ReflectTypeDescriptionProvider.SearchIntrinsicTable (System.Collections.Hashtable table, System.Type callingType) [0x00000] in <00000000000000000000000000000000>:0
at System.ComponentModel.ReflectTypeDescriptionProvider+ReflectedTypeData.GetConverter (System.Object instance) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CanConvertToString (System.Type type) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type type) [0x00000] in <00000000000000000000000000000000>:0

at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary (System.Collections.IDictionary dictionary, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonDictionaryContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id) [0x00000] in <00000000000000000000000000000000>: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 <00000000000000000000000000000000>: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 <00000000000000000000000000000000>: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 <00000000000000000000000000000000>: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 <00000000000000000000000000000000>: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 <00000000000000000000000000000000>: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 <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.JsonSerializer.Deserialize[T] (Newtonsoft.Json.JsonReader reader) [0x00000] in <00000000000000000000000000000000>:0
at ViewController.Start () [0x00000] in <00000000000000000000000000000000>:0

Can't import this package to Unity Project.

Hi,

Thanks for the great open source project. I am wondering why I am not able to import this package into my project? May I know what are the right steps to do it?

Regards,
Jeffrey

JObject->bool[] missing list constructor on ios

Here's the repro code.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Runtime.Serialization;

public class JFail : MonoBehaviour {
    public class JsonFailure {
        public bool[] have_shown_difficulty_hint = new bool[4];

        public JsonFailure() {
            have_shown_difficulty_hint[0] = true;
            have_shown_difficulty_hint[2] = true;
        }
    }

    void Start() {
        JsonFailure original = new JsonFailure ();
        JObject jobject = JObject.FromObject(original);
        Debug.Log("JObject: " + jobject.ToString());

        //Argument lacking list constructor: boolean
        JsonFailure backFromJObject = jobject.ToObject<JsonFailure>();
        Debug.Log("--DONE-- ");
    }
}

And the IOS error.

ExecutionEngineException: Attempting to call method 'System.Collections.Generic.List1[[System.Boolean, mscorlib, Version=2.0.0.0, Culture=, PublicKeyToken=b77a5c561934e089]]::.cctor' for which no ahead of time (AOT) code was generated. 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 at Newtonsoft.Json.Utilities.LateBoundReflectionDelegateFactory+<>c__DisplayClass5_01[T].b__1 () [0x00000] in :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 :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 :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 :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 :0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x00000] in :0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in :0
at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in :0
at Newtonsoft.Json.Linq.JToken.ToObject (System.Type objectType, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00000] in :0
at Newtonsoft.Json.Linq.JToken.ToObject (System.Type objectType) [0x00000] in :0
at JFail.Start () [0x00000] in :0
Rethrow as TypeInitializationException: The type initializer for 'System.Collections.Generic.List<System.Boolean>' threw an exception.
at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
at Newtonsoft.Json.Utilities.LateBoundReflectionDelegateFactory+<>c__DisplayClass5_01[T].<CreateDefaultConstructor>b__1 () [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.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.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <filename unknown>:0 at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <filename unknown>:0 at Newtonsoft.Json.Linq.JToken.ToObject (System.Type objectType, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00000] in <filename unknown>:0 at Newtonsoft.Json.Linq.JToken.ToObject (System.Type objectType) [0x00000] in <filename unknown>:0 at JFail.Start () [0x00000] in <filename unknown>:0 Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. 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 at Newtonsoft.Json.Utilities.LateBoundReflectionDelegateFactory+<>c__DisplayClass5_01[T].b__1 () [0x00000] in :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 :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 :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 :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 :0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x00000] in :0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in :0
at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in :0
at Newtonsoft.Json.Linq.JToken.ToObject (System.Type objectType, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00000] in :0
at Newtonsoft.Json.Linq.JToken.ToObject (System.Type objectType) [0x00000] in :0
at JFail.Start () [0x00000] in :0

Change in Unity Architecture

Hi, I recently stumbled upon this asset and am very impressed. I do have a few suggestions in terms of the Unity Package structure itself.

Instead of the outer folder being called UnityPackages. Could it be changed to JsonNet-Lite and JsonNet . This would follow the Unity Asset Store guide for publishing assets.

I also created an editor script that will allow users to check for updates:
I have attached images of the editor window:

reference001
reference002

Here is the editor unity package:
JsonNetEditor.unitypackage

Failed to Run Seralization weaver with command...

I love JSON.NET and am excited that someone has brought it to Unity3d. I'm using the Unity HoloLens Technical Preview 5.4.0f3-HTP and version 8.0.3 JSON.NET/JSON.NET.Unity3D

I had to use the workaround you've published for UWP apps but I keep running into a runtime exception when trying to parse an OData response to a model I built that represents the response.

Would appreciate your thoughts/suggestions.

Warning: unknown type System.AsyncCallback detected. Using reflection to gather its type information. Consider to reference it from your scripts so it can gathered during the build process.

(Filename: C:\buildslave\unity\build\Runtime/Scripting/Backend/DotNet/ScriptingTypeProvider_DotNet.cpp Line: 153)

Exception thrown: 'System.InvalidOperationException' in mscorlib.ni.dll
InvalidOperationException: Handle is not initialized.
at System.Runtime.InteropServices.GCHandle.FromIntPtr(IntPtr value)
at UnityEngine.Internal.$MethodUtility.CreateInstanceAndInvokeDefaultConstructor(IntPtr type, UIntPtr argument0, Int64* argument1)
at UnityEngineProxy.InternalCalls.PInvokeCalls.JsonUtility_CUSTOM_FromJson(IntPtr param_0, Int32 param_1)
at UnityEngineProxy.InternalCalls.JsonUtility_CUSTOM_FromJson(String json, Type type)
at UnityEngine.JsonUtility.FromJson[T](String json)
at ShowDataOnGaze.d__3.MoveNext()
at UnityEngine.SetupCoroutine.InvokeMoveNext(IEnumerator enumerator, IntPtr returnValueAddress)
at UnityEngine.SetupCoroutine.$Invoke1InvokeMoveNext(Int64 instance, Int64* args)
at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
(Filename: Line: 0)

SerializationBinder and BindToName with Unity 2017

Hi,

I just updated my Unity to the 2017 version, in order to use a more recent (read not so old) version on the mono framework (version 4).

When working with custom SerializationBinder, one should be able to override both BindToName and BindToType methods.

But the fact is that BindToName seems not to be ever called.
Did I miss something, is it due to Json.Net.Unity3D assuming an 'old' version of mono, or is it a bug ?

serializeObject bytes.

[{"values":[{"id":3,"name":"test456","roleType":1,"level":1,"data":{"param1":1,"param2":"MQ=="}}]}]

"MQ==" is not expected. In fact, it should be "1" or 49.

JsonReaderException when json contains empty array

Hi,
We have a problem with your package. Our json looks like that:

{
"status": 1,
"errorCode": [],
"message": "aircraft.listComplete",
"fullErrorMessage": [],
"scriptDateTime": {
"date": "2016-08-19 14:39:29.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"inGameDateTime": {
"date": "2001-04-22 15:56:54.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"irlDateTime": {
"date": "2016-08-19 14:39:29.000000",
"timezone_type": 3,
"timezone": "UTC"
},
}

When parsing, the code throw an exception:

JsonReaderException: Unexpected character encountered while parsing value: [. Path 'errorCode', line 1, position 25.
Newtonsoft.Json.JsonTextReader.ReadNumberValue (ReadType readType) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/JsonTextReader.cs:931)
Newtonsoft.Json.JsonTextReader.ReadAsInt32 () (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/JsonTextReader.cs:424)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonContract contract, Boolean hasConverter) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:2238)
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) (at C:/Project/Github/Json.Net.Unity3D/src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:2389)

How can I solve it?

Question: Version for Unity 2017.1?

Hi.
I have some problems trying to load the binaries from a Unity 2017.1 project. I'm using the latest release.

These are some of the errors that I'm getting:

[ERR 18:48:35.361] AssemblyLoader: Exception loading 'Newtonsoft.Json': System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in :0
at AssemblyLoader.LoadAssemblies () [0x00000] in :0

Additional information about this exception:

System.TypeLoadException: Could not load type 'Newtonsoft.Json.Utilities.EnumUtils+<>c' from assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null'.

System.Reflections.Emit Causes Crash on iOS

Just as the title implies, I'm getting a crash when using IL2CPP in System.Reflections.Emit.]

IL2CPP:DynamicMethod::create_dynamic_method - System.Reflection.Emit is not supported.
  at System.Reflection.Emit.DynamicMethod.CreateDynMethod () [0x00000] in <filename unknown>:0 
  at System.Reflection.Emit.DynamicMethod.CreateDelegate (System.Type delegateType) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDefaultConstructor[T] (System.Type type) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type type) [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
IL2CPP:DynamicMethod::create_dynamic_method - System.Reflection.Emit is not supported.
  at System.Reflection.Emit.DynamicMethod.CreateDynMethod () [0x00000] in <filename unknown>:0 
  at System.Reflection.Emit.DynamicMethod.CreateDelegate (System.Type delegateType) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDefaultConstructor[T] (System.Type type) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type type) [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 Newtonsoft.Json.JsonConvert.DeserializeObject[T]

Just looking for a workaround if possible.

JObject -> HashSet Exception on IOS

As a side note, serializing to string and back works fine on iOS, it just appears to be ToObject.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

public class JFail : MonoBehaviour {

    public class JsonFailure {
        public HashSet<string> foo;
        public JsonFailure() {
            foo = new HashSet<string>();
            foo.Add("HI THERE");
        }
    }
    void Start() {
        JsonFailure original = new JsonFailure();
        JObject jobject = JObject.FromObject(original);
        Debug.Log("JObject: " + jobject.ToString());
        Debug.Log (jobject["foo"].Type.ToString ());

        //Argument Non Null exception on IOS
        JsonFailure backFromJObject = jobject.ToObject<JsonFailure>();
        Debug.Log("---------------------DONE");
    }

}

In editor, this works as expected, but on IOS, the ToObject call exceptions with the following error
(apologies for lack of line number due to il2cpp)

ArgumentNullException: Argument cannot be null.
Parameter name: method
at Newtonsoft.Json.Utilities.ValidationUtils.ArgumentNotNull (System.Object value, System.String parameterName) [0x00000] in :0
at Newtonsoft.Json.Utilities.LateBoundReflectionDelegateFactory.CreateParameterizedConstructor (System.Reflection.MethodBase method) [0x00000] in :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 :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 :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 :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 :0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x00000] in :0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in :0
at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in :0
at Newtonsoft.Json.Linq.JToken.ToObject (System.Type objectType, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00000] in :0
at Newtonsoft.Json.Linq.JToken.ToObject (System.Type objectType) [0x00000] in :0
at JFail.Start () [0x00000] in :0

Publish NuGet package

Would you be willing to maintain a NuGet package for this project?

My team compiles our Unity projects using Visual Studio, so the unitypackage distribution mechanism doesn't work well for us. We are able to unpack the necessary DLLs from the unitypackage, or compile from source, but being able to get an official package from NuGet would be ideal.

Please let me know if you're not familiar with NuGet. I can provide more information/instructions/help/pull requests.

Cities Skylines modding

Hello, is it somehow possible to use this for modding in Cities Skylines which is based on Unity? I mean i have to use net framework 3.5, but i cant get it to work, i probably need code without the conditions to successfully build the mod.

No parameterless constructor defined for 'Newtonsoft.Json.Converters.StringEnumConverter'

2019-08-19 17:48:53.401 26228-26252/com.wismart.mergecity E/Unity: JsonException: No parameterless constructor defined for 'Newtonsoft.Json.Converters.StringEnumConverter'.
at Newtonsoft.Json.Serialization.JsonTypeReflector+<>c__DisplayClass20_0.b__0 (System.Object[] parameters) [0x00000] in <00000000000000000000000000000000>:0
at System.Func`2[T,TResult].Invoke (T arg) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonTypeReflector.GetJsonConverter (System.Object attributeProvider) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract (Newtonsoft.Json.Serialization.JsonContract contract) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreatePrimitiveContract (System.Type objectType) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType) [0x00000] in <00000000000000000000000000000000>:0

JObject ?

Hello.

I would like to know if we can use JObject with your package ?

Visual Studio can't find the type
image

and there is nothing under Newtonsoft.Json.Linq

image

I want to achieve something like that :

image

Can Json.Net.Unity3D run with the .NET 2.0 subset?

I had managed to get Newtonsoft.Json to run in a Unity build for my save/load serialization subsystem. However, it would crash cryptically and horrifically if I ran it as a .NET 2.0 subset build based on the "Api Compatibility Level" in the player settings. If I instead opted for the full .NET 2.0 compatibility, the crashes stopped. I decided that was enough luck for me and swapped it out for Json.Net.Unity3D, but I have had the same crash with the same workaround.

It is a hard problem to nail down because it looks like it's ultimately dying in Mono. I only get a binary dump and it never takes me to the real scene of the crime; even the Unity symbol server isn't helpful here. It's also possible this is some interplay with other things in the project, but I do know it dies in my loader's constructor approximately when it wants to mention a JObject.

il2cpp exception for JArray.Parse on UWP

i get the following error under UWP , it works fine on editor.

JsonReaderException: Error reading JArray from JsonReader. Path '', line 0, position 0. at Newtonsoft.Json.Linq.JArray.Load (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Linq.JsonLoadSettings settings) [0x00000] in <00000000000000000000000000000000>:0 at Newtonsoft.Json.Linq.JArray.Parse (System.String json, Newtonsoft.Json.Linq.JsonLoadSettings settings) [0x00000] in <00000000000000000000000000000000>:0 at Newtonsoft.Json.Linq.JArray.Parse (System.String json) [0x00000] in <00000000000000000000000000000000>:0

JsonArrayContract.CreateWrapper : Argument cannot be null

Hi,

We have a problem with your package with regards to lists and iOS.
We use Unity 5.3.6f1 and build iOS with ILL2CPP.

This is our JSON :

{
"accessToken": {
"token": "[token]"
},
"gameConfig": {
"version": 1,
"balancing": {
"maxGold": [
5000,
10000,
18000,
30000,
50000,
75000,
110000,
150000,
200000,
300000
]
}
}
}

These are our classes :

public class Response
{ 
    public GameConfig gameConfig;
    public AccessToken accessToken;
}

public class GameConfig 
{ 
    public long? version;
    public GameConfigBalancing balancing;
}

public class GameConfigBalancing 
{ 
    public List<double?> maxGold;
}

public class AccessToken 
{ 
    public string token;
}

And this is the error callstack that we receive :

ArgumentNullException: Argument cannot be null.
Parameter name: method
at Newtonsoft.Json.Serialization.JsonArrayContract.CreateWrapper (System.Object list) [0x00000] in :0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewList (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Boolean& createdFromNonDefaultCreator) [0x00000] in :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :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 :0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x00000] in :0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in :0
at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in :0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in :0
at IO.Swagger.Api.UsersApi+c__AnonStorey80.<>m__62 (.ServerResponse i_Response) [0x00000] in :0
at UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) [0x00000] in :0

Are we doing anything wrong with our JSON?
Is there something else than JsonConvert.DeserializeObject(json) that we should use to make it work?

Any help would be appreciated.
Thank you.

Unity iOS (De)SerializeObject<T>() doesnt work

Hi, thanks for your work!

Your fork works very good on my backend and performs well when sending data to frontend desktop Unity client. However on iOS it does not do anything at all. I don't have much data yet, since I'm not really sure how to debug it (and i can't access my project right now but it keeps boggling my mind so thought I'd ask now anyway).

There are no exceptions happening on the iOS. The JSON string is simply empty whenever iOS tries to de-/serialize. Either serializes into empty string or deserializes into empty object.
I have the link.xml in /Assets, I did setup scripting backend to IL2CPP. Have tried .NET 2.0 and .NET 2.0 Subset as well but made no difference.

I guess actually seeing what iOS serializes object into would help, will try that in couple days when get the access.

Would you have any clue as to why this is happening?

Regards,
D

JIT compile method

Hey, thank you for your great work! My code runs great on PC but not on XBOne. The printed error:

ExecutionEngineException: Attempting to JIT compile method 'System.Collections.Generic.GenericEqualityComparer`1<Newtonsoft.Json.Serialization.DefaultSerializationBinder/TypeNameKey>:.ctor ()' while running with --aot-only.

at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod*,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in :0
at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in :0
at System.Activator.CreateInstance (System.Type type) [0x00000] in :0
at System.Collections.Generic.EqualityComparer1[Newtonsoft.Json.Serialization.DefaultSerializationBinder+TypeNameKey]..cctor () [0x00000] in <filename unknown>:0 Rethrow as TypeInitializationException: An exception was thrown by the type initializer for System.Collections.Generic.EqualityComparer1
at System.Collections.Generic.Dictionary2[Newtonsoft.Json.Serialization.DefaultSerializationBinder+TypeNameKey,System.Type].Init (Int32 capacity, IEqualityComparer1 hcp) [0x00000] in :0
at System.Collections.Generic.Dictionary2[Newtonsoft.Json.Serialization.DefaultSerializationBinder+TypeNameKey,System.Type]..ctor () [0x00000] in <filename unknown>:0 at Newtonsoft.Json.Utilities.ThreadSafeStore2[Newtonsoft.Json.Serialization.DefaultSerializationBinder+TypeNameKey,System.Type]..ctor (System.Func`2 creator) [0x00000] in :0
at Newtonsoft.Json.Serialization.DefaultSerializationBinder..ctor () [0x00000] in :0
at Newtonsoft.Json.Serialization.DefaultSerializationBinder..cctor () [0x00000] in :0
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Newtonsoft.Json.Serialization.DefaultSerializationBinder
at Newtonsoft.Json.JsonSerializer.Create () [0x00000] in :0
at Newtonsoft.Json.JsonSerializer.Create (Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in :0
at Newtonsoft.Json.JsonSerializer.CreateDefault () [0x00000] in :0
at Newtonsoft.Json.JsonSerializer.CreateDefault (Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in :0
at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in :0
at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value) [0x00000] in :0
at SaveGame.UpdateFromGame (.Game game) [0x00000] in C:\dev\blackguards-1\Unity\Assets\Scripts\Utils\SaveGame.cs:92

Do you have any idea? Thank you again!

Don't support Mono2x?

Thanks for your great work! It's very useful for me. But when I change Scripting Backend to Mono2x on iOS platform, it can't work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.