J *Object Get Index 0 Value and Save as String

The response from Note.Get is:


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”);

I haven’t tested this yet, but I think you need to use the JGetNumber API instead of JGetObject.

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

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