github.com/prebid/prebid-server@v0.275.0/adapters/smaato/native.go (about) 1 package smaato 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "github.com/prebid/prebid-server/errortypes" 7 ) 8 9 type nativeAd struct { 10 Native json.RawMessage `json:"native"` 11 } 12 13 func extractAdmNative(adMarkup string) (string, error) { 14 var nativeAd nativeAd 15 if err := json.Unmarshal([]byte(adMarkup), &nativeAd); err != nil { 16 return "", &errortypes.BadServerResponse{ 17 Message: fmt.Sprintf("Invalid ad markup %s.", adMarkup), 18 } 19 } 20 adm, err := json.Marshal(&nativeAd.Native) 21 if err != nil { 22 return "", &errortypes.BadServerResponse{ 23 Message: fmt.Sprintf("Invalid ad markup %s.", adMarkup), 24 } 25 } 26 return string(adm), nil 27 }