# Nested map read/get API

**URL:** <https://discuss.aerospike.com/t/nested-map-read-get-api/4030>\
**Category:** Data Types\
**Tags:** query\
**Created:** [April 6, 2017, 5:04pm UTC](https://discuss.aerospike.com/t/nested-map-read-get-api/4030 "2017-04-06T17:04:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sumit\_Kumar](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@Sumit\_Kumar](https://discuss.aerospike.com/u/Sumit_Kumar)\
**Post date:** [April 6, 2017, 5:04pm UTC](https://discuss.aerospike.com/t/nested-map-read-get-api/4030/1 "2017-04-06T17:04:36Z")

</div>

Hi,

I am new to Aerospike (started this week only) and don’t have good hold on the APIs yet. I am trying to build a schema which has only one bin and want to store a nested map structure in this bin. Here is the detail of my nested map data structure. At the first level of map, my key is as an integer (1, 2 etc) and the corresponding value is another map. In the second level of map I want to store two key value pairs, “size” and “data”; something similar like this:

```auto
{
  1: {
    size : 4096,
    data : "aaaa"
  },
  2: {
    size : 2048,
    data : "bbbb"
  }
}

```

I am able to write this into the aerospike db (using c client’s as\_operations\_add\_map\_put\_items operation) but not able to read it back. I can read the first level of map using “`as_operations_add_map_get_by_index(&ops, <bin_name>, 0, AS_MAP_RETURN_VALUE)" and get "{ size : 4096, data : "aaaa" }`” as output but not able to find a way to extract the value from second level of map. I want to read the value of “data” key from the next level of map and looking for right method for that.

Thanks

---

<div class="post-metadata">

**Author:** ![rbotzer](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rbotzer/32/2114_2.png) [@rbotzer](https://discuss.aerospike.com/u/rbotzer)\
**Post date:** [November 7, 2019, 5:01pm UTC](https://discuss.aerospike.com/t/nested-map-read-get-api/4030/2 "2019-11-07T17:01:15Z")

</div>

As of [Aerospike version 4.6](https://www.aerospike.com/blog/aerospike-4-6-enhancing-security-developer-features/) you can apply [list](https://www.aerospike.com/docs/guide/cdt-list.html) and [map](https://www.aerospike.com/docs/guide/cdt-map.html) operations on nested structures at arbitrary depths by defining a [context](https://www.aerospike.com/docs/guide/cdt-context.html). The context is the logical/physical path to finding the nested element you want to operate on.

I wrote a medium post on the topic

> **[Operations on Nested Data Types in Aerospike](https://medium.com/aerospike-developer-blog/operations-on-nested-data-types-in-aerospike-part-i-c17400ffc15b)**
>
> A document store modeling approach
