All Products
Search
Document Center

ApsaraVideo VOD:JSON functions

Last Updated:Jul 10, 2026

ApsaraVideo VOD provides JSON functions for encoding and decoding JSON data in scripts.

json_enc

The following table describes this function.
Item Description
Syntax json_enc(d)
Description Encodes a dictionary object into a JSON string.
Parameter d: the dictionary object to encode.
Return value If the function succeeds, a JSON-encoded string is returned. Otherwise, false is returned.
Example
var_a = []
var_b = ['v1', 'v2']
set(var_a, 'k1', 'v1')
set(var_a, 'k2', var_b)
var_c = '{"k1":"v1","k2":["v1","v2"]}'
say(concat('json_enc=', json_enc(var_a)))
say(concat('json_dec=', get(json_dec(var_c), 'k1')))

Output:
json_enc={"k1":"v1","k2":["v1","v2"]}
json_dec=v1

json_dec

The following table describes this function.
Item Description
Syntax json_dec(s)
Description Decodes a JSON string into a dictionary.
Parameter s: the JSON string to decode.
Return value If the function succeeds, a dictionary is returned. Otherwise, false is returned.
Example
var_a = []
var_b = ['v1', 'v2']
set(var_a, 'k1', 'v1')
set(var_a, 'k2', var_b)
var_c = '{"k1":"v1","k2":["v1","v2"]}'
say(concat('json_enc=', json_enc(var_a)))
say(concat('json_dec=', get(json_dec(var_c), 'k1')))

Output:
json_enc={"k1":"v1","k2":["v1","v2"]}
json_dec=v1