Extracted JSON client functions into seperate package

Solves #317 
That style of `if` is not a feature of Go.