# getObject returns nullptr

**URL:** <https://forum.juce.com/t/getobject-returns-nullptr/33499>\
**Category:** General JUCE discussion\
**Created:** [May 21, 2019, 8:28am UTC](https://forum.juce.com/t/getobject-returns-nullptr/33499 "2019-05-21T08:28:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elan\_Hickler](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@Elan\_Hickler](https://forum.juce.com/u/Elan_Hickler)\
**Post date:** [May 21, 2019, 8:28am UTC](https://forum.juce.com/t/getobject-returns-nullptr/33499/1 "2019-05-21T08:28:52Z")

</div>

Why is getObject() returning nullptr? tracks is a named set in javascript and I need to know the name/key of the indexes and then get the javascript object at each index.

```
    // good
	auto& properties = d->getProperties();
    // good
    if (! properties.contains("tracks"))
    	return Result::fail("project does not contain property 'tracks'");
    // getObject() returns nullptr
    auto t = dynamic_cast<DynamicObject *>(properties.getVarPointer("tracks")->getObject());

    if (t == nullptr)
    	return Result::fail("tracks property is of the wrong type");
```

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [May 21, 2019, 9:05am UTC](https://forum.juce.com/t/getobject-returns-nullptr/33499/2 "2019-05-21T09:05:44Z")

</div>

Well, without the JS code it’s difficult to guess… Is your expected javascript object [actually an object](https://www.w3schools.com/js/js_objects.asp)?

Aside from that, is there a particular reason you aren’t calling `var::getDynamicObject()` instead of doing that work yourself?

---

<div class="post-metadata">

**Author:** ![Elan\_Hickler](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@Elan\_Hickler](https://forum.juce.com/u/Elan_Hickler)\
**Post date:** [May 21, 2019, 2:34pm UTC](https://forum.juce.com/t/getobject-returns-nullptr/33499/3 "2019-05-21T14:34:44Z")

</div>

tracks is a key/object thing. So we are getting the reaper object, then getting its properties, then specifically getting the tracks property and trying to get the name of each index and the contents of each index.

```auto
reaper.tracks["mytrac"] = { name: "myitem", position:0, length:1 };

```

---

<div class="post-metadata">

**Author:** ![Elan\_Hickler](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@Elan\_Hickler](https://forum.juce.com/u/Elan_Hickler)\
**Post date:** [May 22, 2019, 11:38am UTC](https://forum.juce.com/t/getobject-returns-nullptr/33499/4 "2019-05-22T11:38:12Z")

</div>

My issue is resolved. I decided to go for another design and the problem took care of itself. I don’t care to research into this further. Most likely the problem was that there was a difference in the underlying class/object that I did not realize.
