Add a helper function to serialize arrays of model objects to json.