Simplify the code for picking json serialization functions to expose the logic better