move json helpers to lib