question

bunzaga@gmail.com avatar image
bunzaga@gmail.com asked

CatalogItem CustomData == string, ItemInstance CustomData == Dictionary.

I'm not sure if this is intentional or not, but the CustomData property for CatalogItem is a string of an object instead of a Dictionary.

It seems like the CatalogItem CustomData should be parsed to a Dictionary<string, string> just like the ItemInstance CustomData is.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

Ah, my apologies - answering two different (but similar) questions at the same time, and I confused the two classes.

Yes, reviewing the SDKs, the Catalog's CustomData is indeed a string. While I do agree with you that it would be better if this were a Dictionary, that would be a breaking change for existing titles, so I'm afraid we can't do that. If in future we update with added functionality to the Catalog, we will likely choose to change the method's name, so that we can provide new functionality without breaking older titles - in that case, we would be moving to use Dictionary<string,string> in the Catalog as well.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

Actually, this is an error in the API documentation, which we'll get corrected soon. If you look in our SDKs (for example, look for UpdateUserInventoryItemDataRequest in the Unity SDK), you'll see that the custom data is indeed a Dictionary<string, string>.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bunzaga@gmail.com avatar image
bunzaga@gmail.com answered

Yes, you're correct, the ItemInstance is working as intended, but the issue is that the CustomData for an item from the returned Catalog(CatalogItem) is just a string, not a Dictionary.

For example, something like this...

public void OnGetCatalogItemsResult(GetCatalogItemsResult result)
{
foreach (var item in result.Catalog)
{
Debug.Log(item.CustomData); // this is a string, not a Dictionary
}
Release();
}

You would expect that the CustomData from the Catalog would also be a Dictionary (like it is for ItemInstance) but it isn't.

It may not be a 'bug' maybe it is working as it is intended, but when I was writing up some parsing functions, I expected them both to behave the same, and they don't...  I just wanted to mention it, in case it was on accident.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bunzaga@gmail.com avatar image
bunzaga@gmail.com answered

I don't suppose you have any advice on converting that into a Dictionary?  I haven't looked yet, but I'm assuming there must be a similar functionality to parse the ItemInstance.CustomData which I could emulate.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

Yes, if you're using JSON.NET, you could make a call to JsonConvert.DeserializeObject in order to convert the string into the appropriate dictionary.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.