# from\_json() for attribute items

**URL:** <https://discourse.kitware.com/t/from-json-for-attribute-items/77>\
**Category:** Using SMTK\
**Created:** [April 7, 2018, 3:41pm UTC](https://discourse.kitware.com/t/from-json-for-attribute-items/77 "2018-04-07T15:41:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcthomp](https://discourse.kitware.com/user_avatar/discourse.kitware.com/dcthomp/32/10_2.png) [@dcthomp](https://discourse.kitware.com/u/dcthomp)\
**Post date:** [April 7, 2018, 3:41pm UTC](https://discourse.kitware.com/t/from-json-for-attribute-items/77/1 "2018-04-07T15:41:53Z")

</div>

@Haocheng_Liu I’m writing `from_json()` and `to_json()` methods for a new subclass of `smtk::attribute::Item` (ReferenceItem which holds references to `smtk::resource::PersistentObject`) and want to understand why the signature for `from_json` is

```auto
from_json(
  const json& j,
  smtk::attribute::ReferenceItemPtr& itemPtr,
  smtk::attribute::CollectionPtr colPtr)

```

Why do we need to pass in `colPtr`? We should be able to obtain it by calling `itemPtr->attribute()->collection()`, since the item must already have been created before calling `from_json()`. Right?

---

<div class="post-metadata">

**Author:** ![Haocheng\_Liu](https://discourse.kitware.com/user_avatar/discourse.kitware.com/haocheng_liu/32/36_2.png) [@Haocheng\_Liu](https://discourse.kitware.com/u/Haocheng_Liu)\
**Post date:** [April 8, 2018, 5:16pm UTC](https://discourse.kitware.com/t/from-json-for-attribute-items/77/2 "2018-04-08T17:16:35Z")

</div>

Yep. You are right. It’s unncessary.

---

<div class="post-metadata">

**Author:** ![dcthomp](https://discourse.kitware.com/user_avatar/discourse.kitware.com/dcthomp/32/10_2.png) [@dcthomp](https://discourse.kitware.com/u/dcthomp)\
**Post date:** [April 8, 2018, 5:50pm UTC](https://discourse.kitware.com/t/from-json-for-attribute-items/77/3 "2018-04-08T17:50:26Z")

</div>

Good to know I’m not losing my marbles. I’ll either change the signature or create an issue.

---

<div class="post-metadata">

**Author:** ![dcthomp](https://discourse.kitware.com/user_avatar/discourse.kitware.com/dcthomp/32/10_2.png) [@dcthomp](https://discourse.kitware.com/u/dcthomp)\
**Post date:** [April 11, 2018, 3:07am UTC](https://discourse.kitware.com/t/from-json-for-attribute-items/77/4 "2018-04-11T03:07:02Z")

</div>

> [@dcthomp](#):
>
> I’ll either change the signature or create an issue.

For posterity, I change the signature here:  
[https://gitlab.kitware.com/cmb/smtk/merge\_requests/1096](https://gitlab.kitware.com/cmb/smtk/merge_requests/1096)
