Add json encoding
Merge pull request #7 from timhall/json-encode

Add json encoding