Sign In Register

How can we help you today?

Start a new topic

Best way to read/parse AccountDetailsRequest data

Hi guys,


I am new to Gamesparks and working my way through the APIs and commands etc, so sorry for this obviously easy question (I have tried looking on the forums).


What is the best/quickest way to read the json data that returns from the accountdetailsrequest (virtual goods)? Currently I am converting the GSDATA to JSON and parsing it into a string and cutting/trimming it, but is that optimal? I am finding it hard to read the file like a normal Json string (with key reference). Is this possible or do I need to convert it into a dictionary first?


Thanks for any help


  

public void RequestUserDetails()
    {
        
        new AccountDetailsRequest()
            .Send((response) => 
            {
                Debug.Log("User detail request");

                string displayName = response.DisplayName;
                string userId = response.UserId;
                GSData virtualGoods = response.VirtualGoods;
                var vGoods = virtualGoods.JSON;

                Debug.Log(vGoods.ToString());
                
            });
    }

  


Maybe I have to parse into a Dictionary? Unfortunately JsonUltilty (UNITY) doesn't allow this, should I use a 3rd party utility or is there an easier way?

Sorry for replying again. Think I finaly fixed this by using importing Json. Net to convert to dictionary...


Hope this works out.


 Dictionary<string, int> values = JsonConvert.DeserializeObject<Dictionary<string, int>>(vGoods);

 

Login to post a comment