update json protocol to allow function calls. Also simplify list treatment.