<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def on_number(self, ctx, value):
        ''' Since this is defined both integer and double callbacks are useless '''
        value = int(value) if value.isdigit() else float(value)
        top = self._stack[-1]
        if top is JSONCompositeType.OBJECT:
            self.fire(JSONStreamer.VALUE_EVENT, value)
        elif top is JSONCompositeType.ARRAY:
            self.fire(JSONStreamer.ELEMENT_EVENT, value)
        else:
            raise RuntimeError('Invalid json-streamer state')