• Project Info
  • Language
  • C
  • License
  • MIT
  • Version Released
  • Dec. 31, 2020
  • Docs Built
  • March 18, 2021
  • Latest Version
  • master
  • Collaborators
  • admin
  • Tags
  • json

Function cJSON_GetArrayItem

Synopsis

#include <cJSON.h>

cJSON * cJSON_GetArrayItem(const cJSON *array, int index)

Description

Retrieve item number "index" from array "array". Returns NULL if unsuccessful.

Mentioned in

Source

Lines 1866-1874 in cJSON.c. Line 170 in cJSON.h.

CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index)
{
    if (index < 0)
    {
        return NULL;
    }

    return get_array_item(array, (size_t)index);
}


Discussions (1)

Shrikant 1 month ago 0

Is this getting an item indexed at 'index' in fixed time? and its not linear search to get the item in O(n) time, right? Please confirm. The confusion is because cJSON is doubly-linked-list.




Add Discussion as Guest

Log in