func CallbackWithFailResult(param json.JSONObject, reason string) { if param != nil { if !param.HasMember("result") { result := json.NewJSONEmpty() param.Put("result", result) } ok, result := param.GetJSON("result") if ok { result.Put("success", false) result.Put("reason", reason) } Callback(param) } }
func CallbackWithSuccessResult(param json.JSONObject, data json.JSONObject) { if param != nil { if !param.HasMember("result") { result := json.NewJSONEmpty() param.Put("result", result) } ok, result := param.GetJSON("result") if ok { result.Put("success", true) if data != nil { result.Put("data", data) } else { result.Put("data", json.NewJSONEmpty()) } } Callback(param) } }