| --- |
| { |
| "title": "JSON_OBJECT", |
| "language": "en" |
| } |
| --- |
| |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| --> |
| |
| ## json_object |
| ### Description |
| #### Syntax |
| |
| `VARCHAR json_object(VARCHAR,...)` |
| |
| |
| Generate a json object containing the specified Key-Value, |
| an exception error is returned when Key is NULL or the number of parameters are odd. |
| |
| ### example |
| |
| ``` |
| MySQL> select json_object(); |
| +---------------+ |
| | json_object() | |
| +---------------+ |
| | {} | |
| +---------------+ |
| |
| MySQL> select json_object('time',curtime()); |
| +--------------------------------+ |
| | json_object('time', curtime()) | |
| +--------------------------------+ |
| | {"time": "10:49:18"} | |
| +--------------------------------+ |
| |
| |
| MySQL> SELECT json_object('id', 87, 'name', 'carrot'); |
| +-----------------------------------------+ |
| | json_object('id', 87, 'name', 'carrot') | |
| +-----------------------------------------+ |
| | {"id": 87, "name": "carrot"} | |
| +-----------------------------------------+ |
| |
| |
| MySQL> select json_object('username',null); |
| +---------------------------------+ |
| | json_object('username', 'NULL') | |
| +---------------------------------+ |
| | {"username": NULL} | |
| +---------------------------------+ |
| ``` |
| ### keywords |
| json,object,json_object |