当前位置: 首页>>代码示例>>C#>>正文


C# JsonObject.GetNamedObject方法代码示例

本文整理汇总了C#中JsonObject.GetNamedObject方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.GetNamedObject方法的具体用法?C# JsonObject.GetNamedObject怎么用?C# JsonObject.GetNamedObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JsonObject的用法示例。


在下文中一共展示了JsonObject.GetNamedObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SlackChannel

 public SlackChannel(JsonObject source)
 {
     Id = source.GetNamedString("id");
     Name = source.GetNamedString("name");
     var timestampCreation = (int)source.GetNamedNumber("created");
     var offset = DateTimeOffset.FromUnixTimeSeconds(timestampCreation);
     Created = offset.DateTime;
     IsArchived = source.GetNamedBoolean("is_archived", false);
     IsMember = source.GetNamedBoolean("is_member");
     MembersCount = (int)source.GetNamedNumber("num_members");
     var topicObject = source.GetNamedObject("topic");
     Topic = topicObject.GetNamedString("value");
     var purposeObject = source.GetNamedObject("purpose");
     Purpose = purposeObject.GetNamedString("value");
 }
开发者ID:kureuil,项目名称:Taper,代码行数:15,代码来源:SlackChannel.cs

示例2: mapJsonToStudent

 public static Student mapJsonToStudent(JsonObject studentJson)
 {
     JsonObject name = studentJson.GetNamedObject("name");
     Student s = new Student();
     s.name = string.Format("{0} {1}", name.GetNamedString("firstName"),name.GetNamedString("lastSurname"));
     s.id = studentJson.GetNamedString("id");
     return s;
 }
开发者ID:mikeng13,项目名称:slcCampNYC_teamMnM_mobile,代码行数:8,代码来源:Mapper.cs

示例3: Game

        //----------------------------------------------------------------------
        public Game( JsonObject aJsonObject )
        {
            Viewers = Convert.ToInt32( aJsonObject.GetNamedNumber( scViewersString ) );
            Channels = Convert.ToInt32( aJsonObject.GetNamedNumber( scChannelsString ) );

            var theGameObject = aJsonObject.GetNamedObject( scGameString );
            Name = theGameObject.GetNamedString( scNameString );
            ImageUrl = theGameObject.GetNamedObject( scImageUrlString ).GetNamedString( scLargeImageUrlString );
        }
开发者ID:alanebro82,项目名称:Twitch,代码行数:10,代码来源:GameSearchResults.cs

示例4: School

 public School(JsonObject JsonSchool)
 {
     JsonObject schoolobject = JsonSchool.GetNamedObject("education", null);
     if (schoolobject != null)
     {
         Schoolname = schoolobject.GetNamedString("name", "");
         Rank =Convert.ToInt32(schoolobject.GetNamedString("rank", "0"));
     }
 }
开发者ID:Iamnvincible,项目名称:csharppractice,代码行数:9,代码来源:Data.cs

示例5: read

        public override Data read(JsonObject obj)
        {
            Article article = new Article();
            try
            {
                article.Name = obj.GetNamedString("name");
                article.Brand = obj.GetNamedObject("brand").GetNamedString("name");
                JsonArray units = obj.GetNamedArray("units");
                article.Price = units.GetObjectAt(0).GetNamedObject("price").GetNamedString("formatted");
                JsonArray images = obj.GetNamedObject("media").GetNamedArray("images");
                article.ThumbImage = images.GetObjectAt(0).GetNamedString("smallUrl");
            }
            catch(Exception e)
            {
                //TODO: log exception
                System.Diagnostics.Debug.WriteLine(e.Message);
            }

            return article;
        }
开发者ID:shalabi67,项目名称:Search,代码行数:20,代码来源:Article.cs

示例6: ShopDataItem

 public ShopDataItem(JsonObject shopDataObject)
 {
     this.Id = shopDataObject.GetNamedString("id");
     this.Name = shopDataObject.GetNamedString("name");
     if (shopDataObject.Keys.Contains("businessLogo"))
     {
         var urlObj = shopDataObject.GetNamedObject("businessLogo");
         if (urlObj.Keys.Contains("url"))
             this.Logo = urlObj.GetNamedString("url");
     }
     var addressObj = shopDataObject.GetNamedObject("primaryAddress");
     if (addressObj.Keys.Contains("addressLine"))
         this.Address = addressObj.GetNamedString("addressLine");
     if (addressObj.Keys.Contains("latitude"))
         this.Latitiude = addressObj.GetNamedString("latitude");
     if (addressObj.Keys.Contains("longitude"))
         this.Longitude = addressObj.GetNamedString("longitude");
     this.Suburb = addressObj.GetNamedString("suburb");
     this.Categories = new List<ShopCategory>();
     var categoriesObj = shopDataObject.GetNamedArray("categories");
     var catCount = categoriesObj.Count;
     for (uint i = 0; i < catCount; i++)
     {
         var cat = categoriesObj.GetObjectAt(i);
         var catstr = cat.GetNamedString("id");
         if (catstr.Equals("24414"))
             this.Categories.Add(ShopCategory.Handbags);
         else if (catstr.Equals("13927"))
             this.Categories.Add(ShopCategory.Jewellery);
         else if (catstr.Equals("27022"))
             this.Categories.Add(ShopCategory.Shoes);
         else if (catstr.Equals("27642"))
             this.Categories.Add(ShopCategory.Sleepwear);
         else if (catstr.Equals("16373"))
             this.Categories.Add(ShopCategory.Watches);
         else if (catstr.Equals("31917"))
             this.Categories.Add(ShopCategory.Womenswear);
     }
     if (String.IsNullOrEmpty(this.FirstCategory))
         this.FirstCategory = this.Categories.First().ToString();
 }
开发者ID:sugendran,项目名称:clothe-win8,代码行数:41,代码来源:Shop.cs

示例7: OptionalObject

        public static JsonObject OptionalObject(JsonObject jsonObject, string name)
        {
            JsonObject val = null;

            try
            {
                if (jsonObject.ContainsKey(name))
                    if(jsonObject.GetNamedValue(name).ValueType == JsonValueType.Object)
                        val = jsonObject.GetNamedObject(name);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("JsonHelper.OptionalObject(): " + e.Message);
            }

            return val;
        }
开发者ID:WombatWorks,项目名称:windows10-sdk,代码行数:17,代码来源:JsonHelper.cs

示例8: HandleMessage

        protected void HandleMessage(JsonObject message)
        {
            try
            {

            var shouldProcess = true;

            if (Listener != null)
                shouldProcess = Listener.OnReceiveMessage(message);

            if (!shouldProcess)
                return;

            var type = message.GetNamedString("type");
            Object payload = 1;
            try
            {
                payload = message.GetNamedObject("payload");
            }
            // ReSharper disable once EmptyGeneralCatchClause
            catch
            {
                // we will fail when the type is error because payload is not retrievable
            }
            ServiceCommand request = null;
            int id = 0;
            if (message.ContainsKey("id"))
            {
                if (message.ContainsKey("id"))
                {
                    if (message.GetNamedValue("id").ValueType != JsonValueType.String)
                    {
                        id = (int)message.GetNamedNumber("id");
                    }
                    else
                    {
                        var intstr = message.GetNamedString("id");
                        int.TryParse(intstr, out id);
                    }
                }

                try
                {
                    if (Requests.ContainsKey(id))
                        request = Requests[id];
                }
                // ReSharper disable once EmptyGeneralCatchClause
                catch
                {
                    // since request is assigned to null, don't need to do anything here
                }
            }

            if (type.Length == 0)
                return;

            if ("response".Equals(type))
            {
                if (request != null)
                {
                    Logger.Current.AddMessage("Found requests. Need to handle response.");
                    if (payload != null)
                    {
                        try
                        {
                            Util.PostSuccess(request.ResponseListenerValue, payload);
                        }
                        catch
                        {
                        }

                    }
                    else
                    {
                        try
                        {
                            Util.PostError(request.ResponseListenerValue,
                                new ServiceCommandError(-1, "JSON parse error"));
                        }
                        // ReSharper disable once EmptyGeneralCatchClause
                        catch
                        {

                        }
                    }

                    if (!(request is UrlServiceSubscription))
                    {
                        if (!message.ContainsKey("pairingType"))
                        {
                            Requests.Remove(id);
                        }
                    }
                }
            }
            else if ("registered".Equals(type))
            {
                if (!(service.ServiceConfig is WebOsTvServiceConfig))
                {
                    service.ServiceConfig = new WebOsTvServiceConfig(service.ServiceConfig.ServiceUuid);
//.........这里部分代码省略.........
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:101,代码来源:WebOstvServiceSocketClient.cs

示例9: GameSearchResults

        //----------------------------------------------------------------------
        public GameSearchResults( JsonObject aJsonObject )
        {
            Total = Convert.ToInt32( aJsonObject.GetNamedNumber( scTotalString ) );
            Links = new Links( aJsonObject.GetNamedObject( scLinksString ) );

            var theGameList = new List<Game>();
            var theTop = aJsonObject.GetNamedArray( scTopString );
            foreach( var theGame in theTop )
            {
                theGameList.Add( new Game( theGame.GetObject() ) );
            }

            GamesList = theGameList;
        }
开发者ID:alanebro82,项目名称:Twitch,代码行数:15,代码来源:GameSearchResults.cs

示例10:

 void ITmdbObject.ProcessJson(JsonObject jsonObject)
 {
     var o = jsonObject.GetNamedObject("images");
     BaseImageUrl = o.GetSafeString("base_url");
 }
开发者ID:ThadT,项目名称:TMDbWrapper,代码行数:5,代码来源:Configuration.cs

示例11: AssignBaseTypeDetails

        // Depth 1 Assignment (Ltp and NonLtp)
        private static void AssignBaseTypeDetails(LtpCourse ltpCourse, JsonObject courseObject)
        {
            ltpCourse.Slot = courseObject.GetNamedString("slot");
            ltpCourse.Venue = courseObject.GetNamedString("venue");

            AssignTimings(ltpCourse, courseObject.GetNamedArray("timings"));
            AssignAttendance(ltpCourse, courseObject.GetNamedObject("attendance"));

            JsonObject marksObject = courseObject.GetNamedObject("marks");
            AssignMarks(ltpCourse, marksObject);
        }
开发者ID:gitter-badger,项目名称:VITacademics_Windows,代码行数:12,代码来源:JsonParser.cs

示例12: Stream

 //----------------------------------------------------------------------
 public Stream( JsonObject aJsonObject )
 {
     Id = Convert.ToInt64( aJsonObject.GetNamedNumber( scIdString ) );
     Game = aJsonObject.GetNamedString( scGameString );
     Viewers = Convert.ToInt32( aJsonObject.GetNamedNumber( scViewersString ) );
     VideoHeight = Convert.ToInt32( aJsonObject.GetNamedNumber( scVideoHeightString ) );
     AverageFps = Convert.ToInt32( aJsonObject.GetNamedNumber( scAverageFpsString ) );
     Delay = Convert.ToInt32( aJsonObject.GetNamedNumber( scDelayString ) );
     CreatedAt = DateTime.Parse( aJsonObject.GetNamedString( scCreatedAtString ) );
     IsPlaylist = aJsonObject.GetNamedBoolean( scIsPlaylistString );
     Preview = aJsonObject.GetNamedObject( scPreviewString ).GetNamedString( "large" );
     Links = new Links( aJsonObject.GetNamedObject( scLinksString ) );
     Channel = new Channel( aJsonObject.GetNamedObject( scChannelString ) );
 }
开发者ID:alanebro82,项目名称:Twitch,代码行数:15,代码来源:StreamSearchResults.cs

示例13: OnReceiveMessage

            public bool OnReceiveMessage(JsonObject payload)
            {
                try
                {

                var type = payload.GetNamedString("type");

                if (!"p2p".Equals(type)) return true;

                string fromAppId = payload.GetNamedString("from");

                if (!fromAppId.Equals(webOsWebAppSession.GetFullAppId()))
                    return false;

                Object message = payload.GetNamedObject("payload");

                if (message != null)
                {
                    var messageJson = (JsonObject) message;

                    var contentType = messageJson.GetNamedString("contentType");
                    var contentTypeIndex = contentType.IndexOf("connectsdk.", StringComparison.OrdinalIgnoreCase);

                    if (contentTypeIndex >= 0)
                    {
                        //String payloadKey = contentType.Split("connectsdk.",)[1];

                        var payloadKey = contentType.Split('.')[1];
                        if (string.IsNullOrEmpty(payloadKey))
                            return false;

                        var messagePayload = messageJson.GetNamedObject(payloadKey);

                        if (messagePayload == null)
                            return false;

                        if (payloadKey.Equals("mediaEvent", StringComparison.OrdinalIgnoreCase))
                            webOsWebAppSession.HandleMediaEvent(messagePayload);
                        else if (payloadKey.Equals("mediaCommandResponse", StringComparison.OrdinalIgnoreCase))
                            webOsWebAppSession.HandleMediaCommandResponse(messagePayload);
                    }
                    else
                    {
                        webOsWebAppSession.HandleMessage(messageJson);
                    }
                }
                }
                catch (Exception)
                {

                    throw;
                }

                return false;
            }
开发者ID:DmitrySigaev,项目名称:Connect-SDK-Windows,代码行数:55,代码来源:WebOsWebAppSession.cs

示例14: IsValidChildren

 private bool IsValidChildren(JsonObject jsonObject)
 {
     JsonObject data = jsonObject.GetNamedObject("data");
     if (data.Keys.Contains("is_self") && data.GetNamedBoolean("is_self") == false)
     {
         return true;
     }
     return false;
 }
开发者ID:kiewic,项目名称:Projects,代码行数:9,代码来源:SongProcessingTask2.cs

示例15: GetNameValues

        /// <summary>
        /// This is the "Powerhouse"
        /// Get all name-value pairs in the object
        /// - For each value get its value if simple type
        /// - If value is an array get objects in array an recursively call this for each item in the array
        /// - If value is an object call this recursiveky.
        /// </summary>
        /// <param name="preName">Text to prepend to name in list</param>
        /// <param name="oJson">The JSON object</param>
        public static void GetNameValues(string preName, JsonObject oJson)
        {
            foreach (KeyValuePair<string, IJsonValue> oJson_KVP in oJson)
            {
                string prefix = oJson_KVP.Key;
                if (preName != "")
                    //Drilling into an object to indicate using ->
                    prefix = preName + "->" + oJson_KVP.Key;

                //A bit of house keeping: List names are in plural.
               // int n = "address".Length;
               // if (prefix.Substring(prefix.Length - n, n).ToLower() != "address")
               // {
               //     if (prefix.Substring(prefix.Length - 2, 2) == "es")
               //         prefix = prefix.Substring(0, prefix.Length - 2);
               //     else if (prefix.Substring(prefix.Length - 1, 1) == "s")
               //         prefix = prefix.Substring(0, prefix.Length - 1);
               //}

                string typ = oJson_KVP.Value.ValueType.ToString().ToLower();

                if (typ == "object")
                {
                    //Recursively call this for the value
                    GetNameValues(prefix , oJson.GetNamedObject(oJson_KVP.Key));
                }
                else if (typ == "array")
                {            
                    JsonArray ja =  oJson.GetNamedArray(oJson_KVP.Key);
                    //foreach (JsonObject jajo in ja.)
                    for(uint index = 0; index < ja.Count; index++)
                    {
                        string prfx = prefix;
                        if (ja.Count > 1)
                        {
                            //If more than one item in the array, prepend the array index of the item  to the name,
                            NameValues_IsFrom_Array = true;
                            prfx = index.ToString() + ". " + prfx;
                        }
                        JsonObject joja = ja.GetObjectAt(index).GetObject();
                        //Recursively call this for the values in teh array
                        GetNameValues(prfx, joja);
                    }
                }
                else
                {
                    //Got a value to add to list
                    NameValue nv = new NameValue(preName,-1, oJson_KVP);
                }

            }
        }
开发者ID:djaus2,项目名称:IoTSysInfo,代码行数:61,代码来源:SysInfo.cs


注:本文中的JsonObject.GetNamedObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。