All Products
Search
Document Center

MaxCompute:KEYSET_FROM_JSON

Last Updated:Apr 28, 2026

The KEYSET_FROM_JSON function converts a JSON-formatted keyset string to the BINARY type.

Syntax

BINARY KEYSET_FROM_JSON(STRING <json_keyset>)

Parameters

json_keyset: Required. STRING. A JSON-formatted keyset string.

Return value

A keyset of the BINARY type is returned.

Note

You can use HEX to convert the BINARY type into the STRING type or use UNHEX to convert the STRING type into the BINARY type based on your business requirements.

Examples

SELECT HEX(KEYSET_FROM_JSON('{
    "key": [{
            "description": "hello world",
            "key_id": "r8MqZAEA8PDd3QSL",
            "key_meta_data": {
                "key_material_origin": "Origin_ALIYUN_MAXCOMPUTE",
                "key_material_type": "SYMMETRIC",
                "type": "AES-GCM-256",
                "value": "Jqj7ESbfT1td0DwYDmkZVl13FsuykYFe+1u/MPi++a8="},
            "output_prefix_type": "PREFIX_ALIYUN_MAXCOMPUTE",
            "status": "ENABLED"}],
    "primary_key_id": "r8MqZAEA8PDd3QSL"}')) ;

The query returns the following:

+------------+
| _c0        |
+------------+
| 0A1072384D715A414541385044643351534C12580A330A0B4145532D47434D2D323536122026A8FB1126DF4F5B5DD03C180E6919565D7716CBB291815EFB5BBF30F8BEF9AF1801200210011A1072384D715A414541385044643351534C20022A0B68656C6C6F20776F726C64 |
+------------+

Related documentation

Topic

Description

Keyset usage instructions

Describes how to use keyset encryption functions.

NEW_KEYSET

Creates a keyset based on a specified algorithm type.

ADD_KEY_TO_KEYSET

Adds a new key to a keyset and sets it as the master key.

KEYSET_TO_JSON

Converts a BINARY keyset to a readable JSON format to view its details.

ROTATE_KEYSET

Generates a new key and sets it as the master key.

NEW_WRAPPED_KEYSET

Creates a new wrapped keyset by using a role, specified by the role_arn, that has access to a Key Management Service (KMS) customer master key (CMK). You can also use a role_chain to authorize another Alibaba Cloud account to decrypt the keyset.

ROTATE_WRAPPED_KEYSET

Decrypts an existing wrapped keyset, rotates the key, and then re-encrypts the keyset with the new key.

USE_WRAPPED_KEYSET

Converts a wrapped keyset into a basic keyset for use as a parameter in encryption or decryption functions. You can also use this function to obtain and save information about the wrapped keyset for easier maintenance.

ENHANCED_SYM_ENCRYPT

Encrypts data using a specified keyset.

ENHANCED_SYM_DECRYPT

Decrypts data using a specified keyset.