private static bool Parse(AssetStoreResponse response, out string error, out JSONValue jval)
 {
     jval  = default(JSONValue);
     error = null;
     if (response.failed)
     {
         error = string.Format("Error receiving response from server ({0}): {1}", response.HttpStatusCode, response.HttpErrorMessage ?? "n/a");
         return(true);
     }
     try
     {
         JSONParser jsonparser = new JSONParser(response.data);
         jval = jsonparser.Parse();
     }
     catch (JSONParseException ex)
     {
         error = "Error parsing reply from AssetStore";
         DebugUtils.LogError("Error parsing server reply: " + response.data);
         DebugUtils.LogError(ex.Message);
         return(true);
     }
     if (jval.ContainsKey("error"))
     {
         error = jval["error"].AsString(true);
     }
     else if (jval.ContainsKey("status") && jval["status"].AsString(true) != "ok")
     {
         error = jval["message"].AsString(true);
     }
     return(error != null);
 }
        public JSONValue Get(string key, out bool found)
        {
            found = false;
            if (!this.IsDict())
            {
                return(new JSONValue(null));
            }
            JSONValue result = this;

            foreach (string index in key.Split(new char[]
            {
                '.'
            }))
            {
                if (!result.ContainsKey(index))
                {
                    return(new JSONValue(null));
                }
                result = result[index];
            }
            found = true;
            return(result);
        }
        private static string OnPackageReceived(JSONValue jval, Package package)
        {
            string text = "unknown";

            try
            {
                if (!jval.ContainsKey("id"))
                {
                    return(null);
                }
                string empty              = string.Empty;
                string empty2             = string.Empty;
                string empty3             = string.Empty;
                string empty4             = string.Empty;
                string empty5             = string.Empty;
                bool   isCompleteProjects = false;
                string empty6             = string.Empty;
                string empty7             = string.Empty;
                string empty8             = string.Empty;
                text = "id";
                if (!jval[text].IsNull())
                {
                    package.versionId = int.Parse(jval[text].AsString(false));
                }
                text = "name";
                jval.Copy(text, ref empty, false);
                text = "version_name";
                jval.Copy(text, ref empty2, false);
                text = "root_guid";
                jval.Copy(text, ref empty3, false);
                text = "root_path";
                jval.Copy(text, ref empty4, false);
                text = "project_path";
                jval.Copy(text, ref empty5, false);
                text = "is_complete_project";
                jval.Copy(text, ref isCompleteProjects);
                text = "preview_url";
                jval.Copy(text, ref empty6);
                text = "icon_url";
                jval.Copy(text, ref empty7);
                text = "status";
                jval.Copy(text, ref empty8);
                package.Name               = empty;
                package.VersionName        = empty2;
                package.RootGUID           = empty3;
                package.RootPath           = empty4;
                package.ProjectPath        = empty5;
                package.IsCompleteProjects = isCompleteProjects;
                package.PreviewURL         = empty6;
                package.SetStatus(empty8);
                if (!string.IsNullOrEmpty(empty7))
                {
                    package.SetIconURL(empty7);
                }
            }
            catch (JSONTypeException ex)
            {
                return(string.Concat(new string[]
                {
                    "Malformed metadata response for package '",
                    package.Name,
                    "' field '",
                    text,
                    "': ",
                    ex.Message
                }));
            }
            catch (KeyNotFoundException ex2)
            {
                return(string.Concat(new string[]
                {
                    "Malformed metadata response for package. '",
                    package.Name,
                    "' field '",
                    text,
                    "': ",
                    ex2.Message
                }));
            }
            return(null);
        }