wrote json encoder