Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Feature Request get a deserialized object from getJson

Discussion in 'Unity Remote Config' started by Meresman, Aug 23, 2022.

  1. Meresman

    Meresman

    Joined:
    Sep 15, 2019
    Posts:
    6
    Hi, I'm trying to use Remote config services and wondered, why does getJson returns a string and not a deserialized object?
    I noticed JsonConvert is already used to serialize in that class. why not create a - public T GetJson<T>(...)?

    code from RuntimeConfig.cs:
    Code (CSharp):
    1.  
    2.         /// <summary>
    3.         /// Retrieves the string representation of the JSON value of a corresponding key from the remote service, if one exists.
    4.         /// </summary>
    5.         /// <param name="key">The key identifying the corresponding setting.</param>
    6.         /// <param name="defaultValue">The default value to use if the specified key cannot be found or is unavailable.</param>
    7.         /// <returns>A string representation of the JSON value of a corresponding key from the remote service, if one exists. If one does not exist, the defaultValue is returned ("{}" if none is supplied.)</returns>
    8.         public string GetJson(string key, string defaultValue = "{}")
    9.         {
    10.             try
    11.             {
    12.                 return _config[key].ToString();
    13.             }
    14.             catch
    15.             {
    16.                 return defaultValue;
    17.             }
    18.         }
     

    Attached Files: