Add json helper functions, and remove some old, dead code.

This replaces a lot of old and long json-related functions with just a simple call to a helper.