fix for crash when trying to return data of wrong type
using json.dumps to encode dict for transmission