Call json.dumps in one place.
Start to fix up selection stuff.