Xerial
  • Intro
    • ⚡Introduction
    • 🏁Getting Started
    • â„šī¸Before We Start: Important
  • 👷Build
    • Build Your Account
    • Create Your Assets
    • Inventory
    • Marketplace
    • User Flow
    • Best Practices
      • Attribute Guide
        • Attribute Use Cases
  • â˜„ī¸Xerial APIs
    • đŸ—ī¸API Authorization
    • 🛅Wallet API
      • Getting Started
      • Custodial Wallets
        • Create User
        • Create Wallet
        • Get Wallets
      • Wallet Management
        • Get Chain Native Currency Balance
        • Get Supported ERC20 Tokens Balances
        • Get Project Inventory
      • Transaction Proccessing
        • Transfer Xerial NFT
        • Transfer Chain Native Currency
        • Transfer ERC20 Token
        • Primary Purchase Xerial NFT
        • Secondary Purchase
        • List Xerial NFT
        • Delist Xerial NFT
        • Execute Custom Transaction
      • Errors Handling
        • Authentication Errors
        • Wallet Management Errors
        • Transaction Proccessing Errors
    • 🛒Marketplace API
      • Get Listed NFTs
      • Get Community Listed Items
      • Get Collections
      • Get Project Data
    • đŸ–ŧī¸NFT API
      • NFT Drop
    • 🌐Xerial Global Wallets
      • Get User Wallet Info
      • Get Global Inventory
      • User Authorization
      • Logout
  • đŸ› ī¸Xerial SDK
    • Wallet SDK
  • đŸŽī¸Gaming Toolkit
    • đŸ•šī¸Xerial Unity SDK Guide
      • âŦ‡ī¸Installation
      • âš™ī¸Configuration
      • Xerial Services
        • Set Up Xerial Services
        • Service Managers
          • Session Manager
          • Wallet Manager
            • UserData Class
              • Account Class
              • Wallet Class
              • Creating UserData Class
          • Inventory Manager
            • NFTs
              • Metadata
              • Attributes
            • NFTInventory Class
            • Creating NFT Inventory
          • MarketPlace Manager
    • Unreal Engine SDKs
Powered by GitBook
On this page
  • Deserializing Account Data
  • Deserializing Wallet Data
  1. Gaming Toolkit
  2. Xerial Unity SDK Guide
  3. Xerial Services
  4. Service Managers
  5. Wallet Manager
  6. UserData Class

Creating UserData Class

After requesting user data from Xerial services, the JSON response needs to be processed to create an instance of the UserData class.

using System.Collections.Generic;
using Xerial;

public class DeserializeUserData
{
  public UserData ProcessJsonResponse(string jsonResponse)
  {
      // Method implementation
  }
}

Deserializing Account Data

To deserialize the account data from the JSON response, we first retrieve the relevant node from the JSON data and then create an instance of the Account class. Here's how it's done:

Explanation

We extract the "user" object from the JSON data and create a new instance of the Account class. We then assign the values of the "identifier" and "id" properties to the corresponding properties of the Account instance.

Example

// Process the "user" object
JSONNode userNode = jsonNode["user"];
Account user = new Account
{
    identifier = userNode["identifier"],
    id = userNode["id"]
};

Deserializing Wallet Data

To deserialize the wallet data from the JSON response, we iterate through the "wallets" array, create Wallet instances for each object, and collect them in a list. Here's how it's done:

Explanation

We iterate through the "wallets" array in the JSON data. For each object in the array, we create a new Wallet instance and assign its properties by extracting values from the corresponding JSON properties. We then add each Wallet instance to a list.

Example

List<Wallet> walletList = new List<Wallet>();

// Process the "wallets" array
JSONArray walletsArray = jsonNode["wallets"].AsArray;
if (walletsArray != null)
{
    foreach (JSONNode walletNode in walletsArray)
    {
        Wallet wallet = new Wallet
        {
            user = walletNode["user"],
            address = walletNode["address"],         
            smartAccount = walletNode["smartAccount"],
            custodial = walletNode["custodial"].AsBool,
            id = walletNode["id"]
        };
        walletList.Add(wallet);
    }
}

PreviousWallet ClassNextInventory Manager

Last updated 1 year ago

đŸŽī¸
đŸ•šī¸