Feature: support field serialization consistent with Unity
By default Unity serializes public fields, as does LitJson. However the rules are a little more complicated. It should be possible to configure LitJson to directly mimic the serialization behaviour of Unity, most specifically to train it to respect the SerializeField attribute. (Note that this should be done without introducing a compile-time dependency between LitJson and UnityEngine, but rather by having a way to dynamically inject an attribute type or delegate to control what gets serialized.)
Unity will serialize the following types:
- any Unity object
- any custom class (but not struct) marked with System.Serializable attribute
- basic value types (string, float, int, etc.)
- Lists and arrays of serializable types
On these objects, the following will be serialized:
- public fields of serializable types
- private fields marked with the UnityEngine.SerializeField attribute
- -not- properties
More information on serialization from the Unity tech blog.
For insight, I'd suggest switching to text-based meta files and opening a file in notepad. Unity serializes all it's objects using the YAML format, which IIRC is a superset of Json, so developing a strategy here should be straightforward.
The rules are simple enough, as outlined above. Right now there's no way to tell LitJson to serialize private fields, or to look for the SerializeField attribute. (I just hacked support for this into my local branch, but it's not done cleanly.)
mine are not serializing a private array list of a custom derived type. only public ones accepts it. any news ?