refactor api.go
add writeJson
refactor api.go
add writeJson
Update api_test.go to reflect new api.go
Merge branch 'refactor_api_file' of github.com:dotcloud/docker into refactor_api_file
Merge pull request #582 from dotcloud/refactor_api_file

* Api: refactor api.go file to ease the streaming