Add JSON parsing.

And associated utility methods and tests.