bsm/openrtb

Is it possible to process request that has a minor problem with JSON format?

astrekalova opened this issue · 5 comments

I am developing a server in Golang that accepts openRTB requests. Some of the requests that our partners are sending to the server contain minor problems with JSON validity like a wrong type of hyphen ("user":{"customdata":"48474fea-0aa1-45e1-8817-c5070e27448b”}). This kind of problem leads to an error in decoding with json package and initializing a openrtb.BidRequest struct. Is there a way to ignore a field that is not valid but still extract correct information from a request?

Customdata is just an arbitrary string [0], right?

[0]

CustomData string `json:"customdata,omitempty"` // Optional feature to pass bidder data that was set in the exchange's cookie. The string must be in base85 cookie safe characters and be in any format. Proper JSON encoding must be used to include "escaped" quotation marks.

I'm not sure that I understand your point. The problem was that the wrong hyphen character was used, so that the json was invalid syntactically. "customdata" is just an example, it could easily be any other field.

If the JSON is invalid syntactically the only option is to correct it before feeding to json.Unmarshal.

That said hyphen is not a part of JSON syntax, so not sure how it can be wrong.

dim commented

Hi, I don't quite understand the issue with validity. To me, it looks like "user":{"customdata":"48474fea-0aa1-45e1-8817-c5070e27448b”} example should pass just fine. What is exactly the problem?