From 7bd0db0d1d874e3639178edf2fbd61aa59fcaed3 Mon Sep 17 00:00:00 2001 From: "junping.zhao" Date: Tue, 12 May 2020 11:19:42 +0800 Subject: [PATCH] optimized code of native request transform --- adapters/yeahmobi/yeahmobi.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/adapters/yeahmobi/yeahmobi.go b/adapters/yeahmobi/yeahmobi.go index fa74adc008c..f1891e132bd 100644 --- a/adapters/yeahmobi/yeahmobi.go +++ b/adapters/yeahmobi/yeahmobi.go @@ -73,15 +73,23 @@ func transform(request *openrtb.BidRequest) { for i, imp := range request.Imp { if imp.Native != nil { var nativeRequest map[string]interface{} + nativeCopyRequest := make(map[string]interface{}) err := json.Unmarshal([]byte(request.Imp[i].Native.Request), &nativeRequest) + //just ignore the bad native request if err == nil { _, exists := nativeRequest["native"] if exists { continue } - nativeCopy := *request.Imp[i].Native - nativeCopy.Request = "{\"native\":" + request.Imp[i].Native.Request + "}" - request.Imp[i].Native = &nativeCopy + + nativeCopyRequest["native"] = nativeRequest + nativeReqByte, err := json.Marshal(nativeCopyRequest) + //just ignore the bad native request + if err != nil { + continue + } + + request.Imp[i].Native.Request = string(nativeReqByte) } } }