JSON_TO_BSON Funtion - special character
Posted in 2023
Topics: General Discussion
Hello, I would like to store json flux in BSON format in my informix database (espaciallye for using index for futures searchs) but i get some trouble with special characters Here is an example of request : SELECT JSON_TO_BSON('{"nom": "Robert", "ville": "Montréal"}') FROM sysmaster:sysdual; and the response is : SQL Error [U0001]: JSON Syntax error at character 41 How can I manage it ? Thank you in advance for ------------------------------ thibaut vandewalle ------------------------------
Thibaut: It is working for me: > SELECT JSON_TO_BSON('{"nom": "Robert", "ville": "Montréal"}') from sysmaster:sysdual; (constant) * 1 row(s) retrieved. > SELECT JSON_TO_BSON('{"nom": "Robert", "ville": "Montréal"}')::JSON from sysmaster:sysdual; (expression) {"nom":"Robert","ville":"Montréal"} 1 row(s) retrieved. FWIW, you don't need to call JSON_TO_BSON directly, you can just cast it (and if you are running v14.10 you don't necessarily need the FROM clause to fetch a constant): (expression) {"nom":"Robert","ville":"Montréal"} 1 row(s) retrieved. > select '{"nom": "Robert", "ville": "Montréal"}'::JSON::BSON; (constant) * 1 row(s) retrieved. > select '{"nom": "Robert", "ville": "Montréal"}'::JSON::BSON::JSON; (constant) {"nom":"Robert","ville":"Montréal"} 1 row(s) retrieved. > Art ------------------------------ Art S. Kagel, President and Principal Consultant ASK Database Management Corp. www.askdbmgt.com ------------------------------
Hi, I was testing this request with Dbeaver. With Dbacess, it's working. Thanks a lot Thibaut Vandewalle ------------------------------ thibaut vandewalle ------------------------------