Refactor composer json logic.

This sets the object up ready for some unit tests and makes it a bit
more friendly for us.