json functionality and tests