Geen cache-versie.

Caching uitgeschakeld. Standaardinstelling voor deze pagina:ingeschakeld (code DEF204)
Als het scherm te langzaam is, kunt u de gebruikersmodus uitschakelen om de cacheversie te bekijken.

Rechercher dans le manuel MySQL

12.17.2 Functions That Create JSON Values

The functions listed in this section compose JSON values from component elements.

  • JSON_ARRAY([val[, val] ...])

    Evaluates a (possibly empty) list of values and returns a JSON array containing those values.

    1. mysql> SELECT JSON_ARRAY(1, "abc", NULL, TRUE, CURTIME());
    2. +---------------------------------------------+
    3. | JSON_ARRAY(1, "abc", NULL, TRUE, CURTIME()) |
    4. +---------------------------------------------+
    5. | [1, "abc", null, true, "11:30:24.000000"]   |
    6. +---------------------------------------------+
  • JSON_OBJECT([key, val[, key, val] ...])

    Evaluates a (possibly empty) list of key-value pairs and returns a JSON object containing those pairs. An error occurs if any key name is NULL or the number of arguments is odd.

    1. mysql> SELECT JSON_OBJECT('id', 87, 'name', 'carrot');
    2. +-----------------------------------------+
    3. | JSON_OBJECT('id', 87, 'name', 'carrot') |
    4. +-----------------------------------------+
    5. | {"id": 87, "name": "carrot"}            |
    6. +-----------------------------------------+
  • JSON_QUOTE(string)

    Quotes a string as a JSON value by wrapping it with double quote characters and escaping interior quote and other characters, then returning the result as a utf8mb4 string. Returns NULL if the argument is NULL.

    This function is typically used to produce a valid JSON string literal for inclusion within a JSON document.

    Certain special characters are escaped with backslashes per the escape sequences shown in Table 12.22, “JSON_UNQUOTE() Special Character Escape Sequences”.

    1. mysql> SELECT JSON_QUOTE('null'), JSON_QUOTE('"null"');
    2. +--------------------+----------------------+
    3. | JSON_QUOTE('null') | JSON_QUOTE('"null"') |
    4. +--------------------+----------------------+
    5. | "null"             | "\"null\""           |
    6. +--------------------+----------------------+
    7. mysql> SELECT JSON_QUOTE('[1, 2, 3]');
    8. +-------------------------+
    9. | JSON_QUOTE('[1, 2, 3]') |
    10. +-------------------------+
    11. | "[1, 2, 3]"             |
    12. +-------------------------+

You can also obtain JSON values by casting values of other types to the JSON type using CAST(value AS JSON); see Converting between JSON and non-JSON values, for more information.

Two aggregate functions generating JSON values are available. JSON_ARRAYAGG() returns a result set as a single JSON array, and JSON_OBJECTAGG() returns a result set as a single JSON object. For more information, see Section 12.20, “Aggregate (GROUP BY) Functions”.


Zoek in de MySQL-handleiding

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 26/06/2006 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/mysql-rf-json-creation-functions.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:en Manuel MySQL : https://dev.mysql.com/

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut