lynx_value_get_element

Introduction

Read the element from lynx_value of array type by given index.

Syntax

lynx_api_status lynx_value_get_element(lynx_api_env env,
                                       lynx_value object,
                                       uint32_t index,
                                       lynx_value* result)

Parameters

KeyDescription
[in] envThe environment in which lynx value runs, typically nullptr.
[in] objectThe lynx_value to query.
[in] indexThe index of the value to get.
[out] resultlynx_value at index.

Return Value

Returns lynx_api_ok if the API succeeded. Returns lynx_api_array_expected if the types do not match.

Example

After using the extracted result, memory needs to be freed using lynx_value_remove_reference.

lynx_value ret;
lynx_api_status status = lynx_value_get_element(env, array_value, 0, &ret);
if (status != lynx_api_ok) {
  // handle error.
}
// do something
lynx_value_remove_reference(env, ret, NULL);
Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.