implementing toJSON function on Item