LitJSON / litjson

JSON library for the .Net framework
https://litjson.net/
Other
1.37k stars 404 forks source link

Issue Serializing struct with a public static getter #47

Open ssauer opened 9 years ago

ssauer commented 9 years ago

For whatever reason, I would get an infinite loop of recursion in "WriteValue" within the JsonMapper.cs (I believe from line 808) whenever serializing my struct that had this: public static MyStruct zero { get { return new MyStruct(0,0); } }

It would eventually error out with a maxDepth error once depth hit 101 (an expected max depth)

Adding the second check to my new line 814 fixed the issue: if (p_info.CanRead && !p_info.GetGetMethod().IsStatic) {

Hope this helps! Thanks for your time, Steven

unrealTOM commented 5 years ago

i think that's not an acceptable solution, considering that static member is not illegal.