Extracted JSON client functions into seperate package

Closes #317 
I don't think it makes sense to extract this, as it's used exactly once.