added method to json-encode a model, which will be a frequent need.