Redid the to_json stuff to make compact and correct json data types.