Forum OpenACS Development: Removing BOM from JSON

Posted by Iuri Sampaio on
Hi there,

Is there any API method to deal with Bit Order Mark (BOM) from JSON ?

How do I get rid of  , using a proper OACS or TCL standard function to encode/decode a JSON response?

Best wishes,

[16/Dec/2017:11:01:27][2050.b4112b40][-conn:evex:5-] Notice: 200
[16/Dec/2017:11:01:27][2050.b4112b40][-conn:evex:5-] Notice: {"data": {
"status": true,
"items": [{"item_id":"138","name":"Pra Come\u00e7ar","address":"Avenida Manoel Dias da Silva, 1345 - Pituba, Salvador - BA, Brasil","lng":"-38.46403249999997","lat":"-13.0081619","image":"https:\/\/\/uploads\/user_profile\/thumb\/8f076d71c1c4d607076d90b6ccdc7fb5.jpg","price":"0.00","expert_rate":"8"},{"item_id":"139","name":"Su Caf\u00e9 Bar",


2: Re: Removing BOM from JSON (response to 1)
Posted by Iuri Sampaio on
I'm using
set json [string map {"" ""} $json]
But that's a palliative.

I wonder why the JSON structure has been generated with BOM. I already tried to switch the encoding from UTF-8 to ISO-8859-4, but I still haven't found the actual cause of the problem.

Best wishes

3: Re: Removing BOM from JSON (response to 1)
Posted by Gustaf Neumann on
OpenACS (or Tcl) does not generate BOMs, BOMs are not related to json and could appear in any kind of UTF-8 text. The Unicode Standard permits the BOM in UTF-8, but does not require or recommend its use [1]. Probably do you get the json string from some external source (maybe an editor). You should either tell the source, not to generate the BOM, or you should strip it... what you are doing anyhow.


PS: BOM stands for Byte Order Mark.