Automatically remove UTF8 BOM from response

Hi, i’m new here - so sorry if this is a stupid question…

Our server returns UTF8 encoded JSON data with the BOM, this means if I try the standard res.json() etc - K6 errors out with some unexpected character error.

I’ve got around this by creating a small function to call on the res.body, and then I use the return value from that, but this seems really kludgy and I’m sure there must be a better way ?

Am I missing something obvious ?

Hi @zz9pa, welcome to the forum :tada:

I doubt we can do much about this and from the looks of it having BOM on json files is highly discouraged

Implementations MUST NOT add a byte order mark (U+FEFF) to the
beginning of a networked-transmitted JSON text. In the interests of
interoperability, implementations that parse JSON texts MAY ignore
the presence of a byte order mark rather than treating it as an
error.

You are free to open an issue, and at least see if we can figure out some internal solution, but I would argue returning JSON with a BOM probably will break other stuff as well, so it might be a better idea to just not do it ;).

Cheers, I’ll see what I can do about “fixing” the server.