Пример #1
0
        public static Error ParseError(string json)
        {
            try
            {
                if (JsonConvert.DeserializeObject(json) is JArray)
                {
                    // if json is a simple array return null to avoid raising exception while trying to parse it as an error
                    return(null);
                }
            }
            catch (Exception ex)
            {
                //if this is not a json at all
                Debug.LogError(ex.Message);
                return(null);
            }

            Error storeError = FromJson <Error>(json);

            if ((storeError == null) || (!storeError.IsValid()))
            {
                Error.Login loginError = FromJson <Error.Login>(json);
                storeError = loginError?.ToStoreError();
            }
            return(storeError);
        }
Пример #2
0
        public static Error ParseError(string json)
        {
            Error storeError = FromJson <Error>(json);

            if ((storeError == null) || (!storeError.IsValid()))
            {
                Error.Login loginError = FromJson <Error.Login>(json);
                storeError = loginError?.ToStoreError();
            }
            return(storeError);
        }