JSON.cs Error/Bug


First off this is sweet!! Very nice work!!
File: Helpers/JSON.cs
Line: 107
Your iterating over the properties, getting the value, and then trying to serialize that object. In my case property.GetValue() returned null so when Serialize() was called again the targetObject was null which causes an issue on line 74 when trying to add the targetobject to the alreadyProceededObjects.
  1. My Object (Stripped Down) has a SalesPerson property which was null
    public class Employee : PersistentEntity
    public virtual SalesPerson SalesPerson { get; set; }
  2. Line 107 gets the value of the property SalesPerson which is Null and calls Serialize() again but now the targetObject is null.
    var newObj = property.GetValue(targetObject, null).Serialize(currentDepth + 1, alreadyProccededObjects);
  3. Line 74 trows an error when trying to add the hash code to the alreadyProccededObjects list since targetObject Is Null
    For me I just did a null check to verify that property.GetValue(....) returned a value and then called Serialize().


lmf232s wrote Mar 29, 2012 at 1:48 AM

I suppose if I would of read the other two posts I would of known that this is basically been addressed:

codeplanner wrote Apr 6, 2012 at 6:26 PM

Hello Imf232s :)

yes, this issue has been reported and the solution will be worked on as soon as possible. The fix can very well be a month away (at least) :( Lots of stuff to do at work right now...

Hugh thanks for testing and reporting the bug anyway!
I´ve been trying to get some feedback so I love this!


wrote Feb 13, 2013 at 11:09 PM