|
13 | 13 | using System.Text;
|
14 | 14 | using System.Text.RegularExpressions;
|
15 | 15 | using System.Xml.Serialization;
|
| 16 | +using UnityEngine; |
16 | 17 |
|
17 | 18 | #pragma warning disable IDE0063 // Use simple 'using' statement
|
18 | 19 | #pragma warning disable IDE0057 // Use range operator
|
@@ -275,6 +276,10 @@ private static object CreateInstance(object target, Type type, int elementsCount
|
275 | 276 | var elementType = type.GetElementType();
|
276 | 277 | return Array.CreateInstance(elementType, elementsCount);
|
277 | 278 | }
|
| 279 | + if(typeof(String) == type) |
| 280 | + { |
| 281 | + return String.Empty; |
| 282 | + } |
278 | 283 | return Activator.CreateInstance(type);
|
279 | 284 | }
|
280 | 285 | catch (Exception e)
|
@@ -1797,6 +1802,14 @@ public virtual void ApplyEntry(IDictionary dictionary, object target, string key
|
1797 | 1802 |
|
1798 | 1803 | if (value is IDictionary dic)
|
1799 | 1804 | {
|
| 1805 | + // If the Type (the member field type inside of the encapsulating object) is a generic object then it won't have mappable fields to parse to. |
| 1806 | + // Instead we simply set it to the parsed value |
| 1807 | + if (Type == typeof(object)) |
| 1808 | + { |
| 1809 | + var oValue = ChangeType(target, value, Type, options); |
| 1810 | + Accessor.Set(target, oValue); |
| 1811 | + return; |
| 1812 | + } |
1800 | 1813 | var targetValue = GetOrCreateInstance(target, dic.Count, options);
|
1801 | 1814 | Apply(dic, targetValue, options);
|
1802 | 1815 | return;
|
@@ -5116,7 +5129,7 @@ public virtual void AddException(Exception error)
|
5116 | 5129 | throw new ArgumentNullException(nameof(error));
|
5117 | 5130 |
|
5118 | 5131 | if (_exceptions.Count >= MaximumExceptionsCount)
|
5119 |
| - throw new JsonException("JSO0015: Two many JSON errors detected (" + _exceptions.Count + ").", error); |
| 5132 | + throw new JsonException("JSO0015: Too many JSON errors detected (" + _exceptions.Count + ").", error); |
5120 | 5133 |
|
5121 | 5134 | _exceptions.Add(error);
|
5122 | 5135 | }
|
|
0 commit comments