Serialize an Event into JSON.

        Returns
        -------
        str
            JSON-serialized Event.
18276
def tojson(self) -> str:
        
        return json.dumps({
            'event_id': str(self.id),
            'event_type': self.type,
            'schema_name': self.schema_name,
            'table_name': self.table_name,
            'row_id': self.row_id
        })
1175566
def serialize(self):
        
        data = {
            'task_id': self.task_id,
            'retries': self.retries,
            'async': self.async,
            'module': determine_module(self.func),
            'callable': determine_name(self.func),
            'args': self.func_args,
            'kwargs': self.func_kwargs,
            'options': {},
        }

        if self.on_start:
            data['options']['on_start'] = {
                'module': determine_module(self.on_start),
                'callable': determine_name(self.on_start),
            }

        if self.on_success:
            data['options']['on_success'] = {
                'module': determine_module(self.on_success),
                'callable': determine_name(self.on_success),
            }

        if self.on_error:
            data['options']['on_error'] = {
                'module': determine_module(self.on_error),
                'callable': determine_name(self.on_error),
            }

        return json.dumps(data)
230060
def to_json(self):
    
    # Use the member variable (since we don't have access to the context) to
    # flush each pool to minimize the size of each filehandle before we
    # serialize it.
    for pool in self._pools:
      if pool is not None:
        pool.flush(True)
    return {"filehandles": pickle.dumps(self._filehandles)}
1368334
def serialize(self):
        

        if self.response is not None:
            return {'messaging_type': 'RESPONSE'}

        if self.update is not None:
            return {'messaging_type': 'UPDATE'}

        if self.tag is not None:
            return {
                'messaging_type': 'MESSAGE_TAG',
                'tag': self.tag.value,
            }

        if self.subscription is not None:
            return {'messaging_type': 'NON_PROMOTIONAL_SUBSCRIPTION'}
4493
def event_detail(self, event_detail):
        
        if event_detail is not None:
            if isinstance(event_detail, str):
                self._event_detail = event_detail
            else:
                try:
                    for key, val in event_detail.items():
                        if isinstance(val, date):
                            event_detail[key] = str(val)
                    self._event_detail = json.dumps(event_detail)
                except TypeError:
                    raise TypeError('Passed in event detail object are not json serializable.Please check the format')
314079
def class_to_json(obj):
    

    obj_raw = serialize(obj)

    return json.dumps(obj_raw, indent=_JSON_INDENT, sort_keys=True)
127638
def ToJson(self):
        
        obj = {
            'usage': self.Usage,
            'data': '' if not self.Data else self.Data.hex()
        }
        return obj
264104
def from_dict(event_dict):
    
    return SnippetEvent(
        callback_id=event_dict['callbackId'],
        name=event_dict['name'],
        creation_time=event_dict['time'],
        data=event_dict['data'])
1091499
def serialize(self):
        
        try:
            return jsonpickle.encode(self, unpicklable=False)
        except Exception:
            log.exception("got an exception during serialization")
726170
def to_json(self, indent=None, sort_keys=True):
        
        return json.dumps(self.to_dict(), indent=indent, sort_keys=sort_keys)
726158
def serialize(self, content):
        
        content = super(JSONPEmitter, self).serialize(content)
        callback = self.request.GET.get('callback', 'callback')
        return u'%s(%s)' % (callback, content)
1159235
def format_json(event, colored):
        

        try:
            if event.message.startswith("{"):
                msg_dict = json.loads(event.message)
                event.message = json.dumps(msg_dict, indent=2)
        except Exception:
            # Skip if the event message was not JSON
            pass

        return event
732296
def _events(self):
        
        with self.app.events_lock:
            res = self.app.get_events()
        return serialize(res, True)
1164383
def tojson(self):
        
        json_str = ctypes.c_char_p()
        check_call(_LIB.MXSymbolSaveToJSON(self.handle, ctypes.byref(json_str)))
        return py_str(json_str.value)
1280869
def get_events(self):
        
        res = self.con.get('_events', wait=False)
        logger.debug("Got events from %s: %s", self.name, res)
        return unserialize(res, True)
659353
def to_json(self):
        

        result = super(Space, self).to_json()
        result.update({'name': self.name})
        return result
77016
def publish_event(self, data, suffix=''):
        
        try:
            event_type = data.pop('event_type')
        except KeyError:
            return {'result': 'error', 'message': 'Missing event_type in JSON data'}

        return self.publish_event_from_dict(event_type, data)