LitJSON Problem

Hi i am trying to de/serialize objects in unity3d , i am using the dll from LitJson which is working fine for deserializing the server messages, however, when i try to use JsonMapper.ToJson with an object, i get a null reference Exception.

Any ideas?

my code is like this:

MyObject.data1 = "sample data"; MyObject.data2 = "sample data"; MyObject.data3 = "sample data";

customString = JsonMapper.ToJson(MyObject);

and the error is:

NullReferenceException

System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] System.Reflection.MonoProperty.GetValue (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] index, System.Globalization.CultureInfo culture) [0x00000] System.Reflection.PropertyInfo.GetValue (System.Object obj, System.Object[] index) [0x00000] LitJson.JsonMapper.WriteValue (System.Object obj, LitJson.JsonWriter writer, Boolean writer_is_private, Int32 depth) LitJson.JsonMapper.ToJson (System.Object obj) CreditCardGenerated.OnAddButtonClick () (at Assets\Windows\Account Registration\Account Entry\CreditCardGenerated.cs:429) CreditCardGenerated.DoMyWindow (Int32 windowID) (at Assets\Windows\Account Registration\Account Entry\CreditCardGenerated.cs:302) UnityEngine.GUI+_Window.Do () System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]

Any Ideas?

Thanks

try it: http://code.google.com/p/litjsonmd/