BookmarkSubscribeRSS Feed
-MM-
Calcite | Level 5

We've found out that bserverj is clever when working with JSON codes. When creatives are defined as HTML source, response looks like: ["<p>code one</p>", "<p>code two</p>", "etc."]. But when there is JSON, response is not ["{ \"ad\": \"structure one\" }", "<p>code two</p>"] as expected, but its [{ "ad": "structure one" }, "<p>code two</p>"] – which is fine! It's nice there is some JSON detection that optimizes away JS structure escaping.

 

But there is an error when there are snippets. When there is snippet with code "foo" for type text/html, bserverj returns something like:

[{ "ad": "structure one" }foo, "<p>code two</p>foo"]

... it just pastes that snippet at the end. Result is invalid JSON. We can maybe detect it and parse it away before parsing JSON, but we think it's an obvious error inside bserverj. Could you please acknowledge there is such a bug and maybe even fix it?

 

There are few possible fixes:

1. Easiest one is to detect JSON creative after adding snippet, not before... and if the result after adding snippet is not valid JSON, treat it as HTML string (= make JS string).

2. Put snippets inside some JSON field, so there is something like { "ad": "structure", "_sassnippets": ["foo"] }.

3. When there is creative and some snippets, wrap them in another array, so the response is [[{ "ad": "structure one" }, "foo"], "<p>code two</p>foo"].

4. Remove from bserverj all text/html snippets and invent some new way to define application/json snippet (maybe snippet can be JSON too and then you can merge).

5. Remove all snippets from bserverj. That would be unpleasant for us, since we are currently using snippets. Please don't consider doing this 🙂

 

Thank you.

5 REPLIES 5
-MM-
Calcite | Level 5

In case you don't have any plans to fix this, we can create workaround – use some regular expressions to fix your invalid JSON response (wrap our snippet into JSON field) before parsing. But if we do this, we would like to have some guarantees that you really don't have any plans to fix this bug... because fixing it after this could probably break our workaround.

 

Or if you have any other suggestions (are we maybe doing something wrong?), we are all ears. 😉

Thank you.

BrianJones
SAS Employee

There is a configuration that can be enabled that would only attach snippets to HTML or Javascript creatives.  Please open a support request (support@sas.com) and we will resolve your issue there.

-MM-
Calcite | Level 5

Thank you for your response. Our snippet already has MIME type text/html (and creative is application/json). Yet it's attached to bserverj output.

MatejNovakCruxo
Calcite | Level 5

If I correctly understand your issue, the solution is to add the %%EXTRAHTML%% token to your creative format template. See https://documentation.sas.com/doc/en/iapcdc/1.0/iapug/tokens-predefined.htm

Without the token, the snippet is appended to the end of creative which corrupts the JSON.

When the token is present, the snippet is inserted correctly.

See https://optimics-ads.aimatch.com/optimics/bserverj/ball/site=test/area=def/size=exmample-json/afmt=j... which is using this template: {"creativeCode":"%%X_CODE%%","snippet":"%%EXTRAHTML%%"}

MatejNovakCruxo_1-1694103743714.png

MatejNovakCruxo_1-1694104258711.png

 

Vs. https://optimics-ads.aimatch.com/optimics/bserverj/ball/site=test/area=def/size=exmample-json/afmt=j...

which is using this template: {"creativeCode":"%%X_CODE%%"}

MatejNovakCruxo_0-1694103721305.png

MatejNovakCruxo_0-1694104234686.png

 

 

-MM-
Calcite | Level 5

Thank you, Pachollini! That's probably the answer I was looking for.

What a pleasant surprise to get this response from you… 😁

 

Sometimes we don't have JSON in our template but we get it from partner (bidding from Adform).

So we (probably) can't add %%EXTRAHTML:URLENCODED%% inside… but we still need the information from that snippet.