Extracted JSON client functions into seperate package

For #317