bayatgames / jsonformatter Goto Github PK
View Code? Open in Web Editor NEWEasy, Fast and Lightweight Json Formatter. (Serializer and Deserializer)
Easy, Fast and Lightweight Json Formatter. (Serializer and Deserializer)
TargetParameterCountException: parameters do not match signature
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:188)
System.Reflection.MonoProperty.GetValue (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] index, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoProperty.cs:297)
BayatGames.Serialization.Formatters.Json.JsonTextWriter.WriteObject (System.Object value, System.Type type) (at Assets/BayatGames/JsonFormatter/Scripts/JsonTextWriter.cs:218)
BayatGames.Serialization.Formatters.Json.JsonTextWriter.Write (System.Object value) (at Assets/BayatGames/JsonFormatter/Scripts/JsonTextWriter.cs:93)
BayatGames.Serialization.Formatters.Json.JsonFormatter.Serialize (System.IO.TextWriter output, System.Object value) (at Assets/BayatGames/JsonFormatter/Scripts/JsonFormatter.cs:121)
BayatGames.Serialization.Formatters.Json.JsonFormatter.Serialize (System.Object value) (at Assets/BayatGames/JsonFormatter/Scripts/JsonFormatter.cs:98)
BayatGames.Serialization.Formatters.Json.JsonFormatter.SerializeObject (System.Object value) (at Assets/BayatGames/JsonFormatter/Scripts/JsonFormatter.cs:196)
Assets.Editor.DefaultObjects.Save () (at Assets/Editor/DefaultObjects.cs:108)
Assets.Editor.DefaultObjects.OnGUI () (at Assets/Editor/DefaultObjects.cs:62)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:295)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:288)
UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:255)
First of all, thank you for this JsonFormatter!
I had some more complex data structures in my game and needed to fix some issues and cornercases.
Perhaps you are interested into adding these to the repository:
Currently, bool values are written as {} and crash on reading.
In JsonTextReader line 105 add: type == typeof(bool) ||
In JsonTextWriter line 84 add: type == typeof(bool) ||
The Reader crashes on deserializing an empty dictionary ("{}")
the for loop in line 177 of JsonTextReader should only be executed if there are any values in the dictionary like this:
if (items.Length > 1)
{
for ...
}
When implementing a custom IEnumerable, deserialization fails
In JsonTextWriter line 124 explicitly check for lists and arrays:
else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>) || (type.IsArray))
This should check for the exact same types as the JsonReader to avoid issues on deserialization.
There might be a similar issue with custom IDictionary, but I do not have these in my project.
A null value of a string is read to "ul" due to line 103 in JsonTextReader
I added a null check there:
if("null".Equals(json))
{
return null;
}
I tried manually adding [SerializeField] to my private attributes but they are not serialized regardless
Private attributes are only checked in GetField/GetProperty/GetFields/GetProperties if binding flags are set. I set them to: BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance
However, in my project pretty much all private fields within a savegame are to be serialized so I did not check for the [SerializeField] flag either.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.