private static void serializeCallbackResult(JsonWriter writer, CallbackResult result) { if (result == null) { writer.Write(null); } else { writer.WriteObjectStart(); writer.WritePropertyName("type"); if (result is FlowCallbackResult) writer.Write("flow"); else if (result is MessageCallbackResult) writer.Write("message"); else if (result is FormCallbackResult) writer.Write("form"); writer.WritePropertyName("value"); result.Write(writer, false); writer.WriteObjectEnd(); } }