To json

refactored to use ruby hashes/arrays and to_json.