toJSON for client written