# J \*Object Get Index 0 Value and Save as String

**URL:** <https://discuss.blues.com/t/j-object-get-index-0-value-and-save-as-string/256>\
**Category:** Uncategorized\
**Created:** [May 10, 2021, 11:17pm UTC](https://discuss.blues.com/t/j-object-get-index-0-value-and-save-as-string/256 "2021-05-10T23:17:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![webuser1](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@webuser1](https://discuss.blues.com/u/webuser1)\
**Post date:** [May 10, 2021, 11:17pm UTC](https://discuss.blues.com/t/j-object-get-index-0-value-and-save-as-string/256/1 "2021-05-10T23:17:40Z")

</div>

The response from Note.Get is:

{“body”:{“foo”:“ABC”,“bar”:“ABC”},“time”:1620614032}

I can get the 2 values from object “body” just fine.

J \*body = JGetObject(rsp, “body”);

String return\_val1 = JGetString(body, “foo”);  
String return\_val2 = JGetString(body, “bar”);

But how do I get the object “time” and save its value to a string? Since it’s the first value with index 0 can’t reference it like before.

J \*object\_time = JGetObject(rsp, “time”);

This gives an error

String return\_val3 = JGetString(object\_time, “time”);

---

<div class="post-metadata">

**Author:** ![zfields](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/zfields/32/29_2.png) [@zfields](https://discuss.blues.com/u/zfields)\
**Post date:** [May 10, 2021, 11:36pm UTC](https://discuss.blues.com/t/j-object-get-index-0-value-and-save-as-string/256/2 "2021-05-10T23:36:09Z")

</div>

I haven’t tested this yet, but I think you need to use the [`JGetNumber` API](https://github.com/blues/note-c/blob/master/n_cjson_helpers.c#L137) instead of `JGetObject`.

In this circumstance, `time` is a JSON `Number` and not an object (`{}`).

---

<div class="post-metadata">

**Author:** ![webuser1](https://avatars.discourse-cdn.com/v4/letter/w/aca169/32.png) [@webuser1](https://discuss.blues.com/u/webuser1)\
**Post date:** [May 11, 2021, 12:16am UTC](https://discuss.blues.com/t/j-object-get-index-0-value-and-save-as-string/256/3 "2021-05-11T00:16:15Z")

</div>

Thanks again! It makes sense now that it’s not an object but just a number and similar to Card.Time request.

JTIME return\_val3 = 0;  
return\_val3 = JGetInt(rsp, “time”); //rsp is original response object
