added toJSON function
added implementation for post