|
|
@@ -21,6 +21,7 @@ namespace JCUnityLib
|
|
|
importerDict.Add(typeof(double), (o) => JValue.FromObject(o));
|
|
|
importerDict.Add(typeof(bool), (o) => JValue.FromObject(o));
|
|
|
importerDict.Add(typeof(double[][]), (o) => JArray.FromObject(o));
|
|
|
+ importerDict.Add(typeof(Nullable<bool>), (o) => JValue.FromObject(o));
|
|
|
//add exporter
|
|
|
exporterDict.Add(typeof(short), (jt) => jt.ToObject<short>());
|
|
|
exporterDict.Add(typeof(int), (jt) => jt.ToObject<int>());
|
|
|
@@ -29,6 +30,7 @@ namespace JCUnityLib
|
|
|
exporterDict.Add(typeof(double), (jt) => jt.ToObject<double>());
|
|
|
exporterDict.Add(typeof(bool), (jt) => jt.ToObject<bool>());
|
|
|
exporterDict.Add(typeof(double[][]), (jt) => ((JArray)jt).ToObject<double[][]>());
|
|
|
+ exporterDict.Add(typeof(Nullable<bool>), (jt) => jt.ToObject<Nullable<bool>>());
|
|
|
}
|
|
|
|
|
|
public void InitJsonClass<T>(Func<object, JToken> importer, Func<JToken, object> exporter)
|
|
|
@@ -71,7 +73,7 @@ namespace JCUnityLib
|
|
|
{
|
|
|
FieldInfo targetField = fromObjectType.GetField(propertyName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
|
|
if (targetField == null) {
|
|
|
- PropertyInfo propertyInfo = fromObjectType.GetProperty(propertyName);
|
|
|
+ PropertyInfo propertyInfo = fromObjectType.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
|
|
JToken propertyValue = ToJTokenByImporter(propertyInfo.GetValue(fromObject));
|
|
|
target[propertyName] = propertyValue;
|
|
|
} else {
|
|
|
@@ -133,7 +135,7 @@ namespace JCUnityLib
|
|
|
{
|
|
|
FieldInfo targetField = targetType.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
|
|
if (targetField == null) {
|
|
|
- PropertyInfo propertyInfo = targetType.GetProperty(fieldName);
|
|
|
+ PropertyInfo propertyInfo = targetType.GetProperty(fieldName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
|
|
object fieldValue = ParseByExporter(fromJson[fieldName], propertyInfo.PropertyType);
|
|
|
propertyInfo.SetValue(target, fieldValue);
|
|
|
} else {
|