question

duartedd avatar image
duartedd asked

having issues desieralizing the functionresult JSON object from my FindDuel Cloudscript call

Hello I am wondering if you could help me understand what the issue is for my FindDuel call the functionresult appears golden in postman but when i deserialize it in unity it ios giving me a null reference error

JsonWrapper.DeserializeObject<List<DuelEnemy>>(result.FunctionResult.ToString());

the function result returns 3 objects which should deserialize into a DuelEnemyList accordingly.


 public class DuelEnemy
{
    public string CharacterID;
    public string KeeperName;
    public int Health;
    public int Power;
    public int Temper;
    public int Cultivation;
    public string damagetype;
    public InventoryCategory inventory;
    public List<string> EnemyDuelDeck;
}

have any suggestions to try and troubleshoot this - the reference error goes back to simpleJSON.cs file which im not positive what the issue is there...perhaps it cant translate something into an object? not everything returned I need for instance there is some data about VCs that isnt used - will that cause issues if there is no variable in the DuelEnemy class?

thanks again a billion times over for all your guys' help!

1 comment
10 |1200

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

JayZuo avatar image JayZuo ♦ commented ·

What's the result returned from your FindDuel function? Please share a sample FunctionResult, so that we can help you further.

0 Likes 0 ·

1 Answer

·
duartedd avatar image
duartedd answered

Hey again JayZuo! - the whole functionresult is kind of long - but i figured it out after i looked at the code further and compared the functionresult - the issue was the Inventory section

what happened was i waas deserializing the result but within that result of inventory i had an inventory result which had not been deserialized

so what i did INSTEAD since i dont need the other data was just return the actual 'Inventory' section of the getcharacterinventory result and match it to the 'inventory' property -

hope this helps anyone in the future if they run into it

thanks for always replying and always willing to help!

  "FunctionResult": [
     {
         "CharacterID": "1CFD8FB66AE2CEF4",
           "KeeperName": "sdfdasads", 
           "damagetype": "PhysicalDamage",
           "inventory": [
                    { 
                 "PlayFabId": "EA9AAEB0647A14E0",
                 "CharacterId": "1CFD8FB66AE2CEF4",
            "Inventory": [
                   {
                       "ItemId": "LeatherLeggings",            
"ItemInstanceId": "1F7DBC3DBB714F83", "ItemClass": "Legs", "DisplayName": "Leather Leggings", "UnitPrice": 0 } } ]
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.