Make HSON encoder into a class