Extracted JSON client functions into seperate package

Closes #317 
@titanous Okay, I've renamed the function to newClient, and moved some code around to reduce repetitiveness.