what is "*&" in TryGetObject function

Hi,

I’m loading in some JSON data and am trying to verify if it is what I expected. Since I’m expecting an object I use the FJsonValue::TryGetObject function, this function expects

const TSharedPtr< FJsonObject > *& Object

I have no idea how I can convert from a

TSharedPtr< FJsonObject >

to a

const TSharedPtr< FJsonObject > *& Object.

Someone here who can help me? Thank you in advance.

Hi,

It’s a ‘reference to a pointer to a const TSharedPtr of FJsonObject’. It makes slightly more sense if you put the const on the other side of the type and read it backwards:

TSharedPtr< FJsonObject > const *&

So you don’t pass a TSharedPtr< FJsonObject >, you pass a pointer to a const one:

const TSharedPtr< FJsonObject >* Ptr;
if (FJsonValue::TryGetObject(Ptr))
{
    // If you get here, Ptr will be pointing to the FJsonObject,
    // which you can then access via the TSharedPtr
}

Hope this helps.

Steve

1 Like

Thnx! It works now :slight_smile: