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