Add functionality to encode an object to a buffer using a specification
Change if else chains to be switch statements