json encoding of events now working