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


C# JsonObject.GetNamedArray方法代码示例

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


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

示例1: mapAssessmentJsonToAssessment

        public static Assessment mapAssessmentJsonToAssessment(JsonObject assessmentJson)
        {
            Assessment assessment = new Assessment();
            assessment.id = assessmentJson.GetNamedString("id");
            assessment.title = assessmentJson.GetNamedString("assessmentTitle");
            assessment.subject = assessmentJson.GetNamedString("academicSubject");
            assessment.category = assessmentJson.GetNamedString("assessmentCategory");

            var studentAssessmentArray = assessmentJson.GetNamedArray("studentAssessmentAssociation");
            var studentAssessment = studentAssessmentArray[0].GetObject();

            try
            {
                var startDate = studentAssessment.GetNamedString("administrationDate");
                if (startDate != null) assessment.startDate = DateTime.Parse(startDate);

                var endDate = studentAssessment.GetNamedString("administrationEndDate");
                if (endDate != null) assessment.endDate = DateTime.Parse(endDate);

                var scoreResults = studentAssessment.GetNamedArray("scoreResults");
                var firstScore = scoreResults[0];
                assessment.score = firstScore.GetObject().GetNamedString("result") + "/" + assessmentJson.GetNamedNumber("maxRawScore");
            }
            catch (Exception e)
            {

            }
            assessment.description = "Bacon ipsum dolor sit amet meatloaf tail doner, sausage pig jowl flank chicken beef ribs drumstick leberkas ham rump ball tip prosciutto. Boudin pig prosciutto, leberkas ball tip meatloaf ham hock hamburger ribeye salami beef jerky. Pork belly pork chop tongue pancetta salami biltong capicola meatloaf prosciutto pastrami sirloin spare ribs. Tri-tip filet mignon tail beef ribs. Biltong flank ribeye short ribs, cow ground round brisket jerky pork.\n\n Turkey frankfurter meatball, shank fatback ball tip boudin shankle chuck. Shankle shoulder shank pig ham turkey brisket pork chop filet mignon. Strip steak sausage turkey, shank fatback filet mignon hamburger jowl. Pig bacon drumstick, swine chicken sausage prosciutto brisket strip steak doner ham pork loin bresaola shank. Doner beef capicola fatback pork belly, pork chop t-bone shank turducken andouille corned beef. Tail turducken sausage andouille chuck kielbasa pig bacon corned beef t-bone flank beef. Tenderloin chicken sirloin, tail swine turkey short ribs tongue meatball capicola ham spare ribs filet mignon kielbasa meatloaf.";
            return assessment;
        }
开发者ID:mikeng13,项目名称:slcCampNYC_teamMnM_mobile,代码行数:30,代码来源:Mapper.cs

示例2: loadJsonInfo

        async private void loadJsonInfo() 
        {
            try
            {
                //--------- Having content from website--------------
                HttpClient http = new HttpClient();
                var response = await http.GetByteArrayAsync("http://emresevinc.github.io/exrepo.html");
                String source = Encoding.GetEncoding("utf-8").GetString(response, 0, response.Length - 1);
                source = WebUtility.HtmlDecode(source);
                HtmlDocument resultat = new HtmlDocument();
                resultat.LoadHtml(source);

                List<HtmlNode> toftitle = resultat.DocumentNode.Descendants().Where
                    (x => (x.Name == "div" && x.Attributes["class"] != null &&
                    x.Attributes["class"].Value.Contains("container"))).ToList();
                String text = toftitle[0].InnerText;

                selectedMovie = new Movie();
                //----------------------------------------------------
                _jObject = JsonObject.Parse(text);  // Burada json dosyası parse ediliyor.
                jArr = _jObject.GetNamedArray("movies"); // Json verileri içindeki movies array'i
                fillToMovieList();
            }
            catch (Exception)
            {
               new MessageDialog("Bir hata gerceklesti").ShowAsync();
            }
        }
开发者ID:emresevinc,项目名称:WindowsApp,代码行数:28,代码来源:MainPage.xaml.cs

示例3: Update

 //note the async keyword - it's cause we're using an "await" method in our method body
 public async void Update()
 {
     var client = new HttpClient();
     //ooh fancy new await syntax!
     //this actually executes in parallel and pauses the rest of the method's execution until it returns
     //(in a non blocking way of course)
     var result = await client.GetAsync(string.Format("http://search.twitter.com/search.json?q={0}&since_id={1}", SearchTerm, Since));
     var root = new JsonObject(result.Content.ReadAsString());
     var array = root.GetNamedArray("results");
     for(int i = 0; i < array.Count; i++) 
     {
         var element = array[i];
         JsonObject obj = element.GetObject();
         Tweet tweet = new Tweet
         {
             created_at = obj.GetNamedString("created_at"),
             from_user = obj.GetNamedString("from_user"),
             id_str = obj.GetNamedString("id_str"),
             profile_image_url = obj.GetNamedString("profile_image_url"),
             text = obj.GetNamedString("text")
         };
         if (!Tweets.Any(t => t.id_str == tweet.id_str))
         {
             Tweets.Insert(0, tweet);
         }
     }
 }
开发者ID:ChadMcCallum,项目名称:Windows8Examples,代码行数:28,代码来源:TwitterSearchModel.cs

示例4: 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

示例5: 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

示例6: 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

示例7: ParseExtentedBookItem

 private static ExtendedBookItem ParseExtentedBookItem(JsonObject j)
 {
     var book = new ExtendedBookItem();
     book.SeriesId = ((int)j.GetNamedNumber("_id")).ToString();
     book.Title = j.GetNamedString("name");
     book.CoverImageUri = j.GetNamedString("cover");
     book.Publisher = j.GetNamedString("publisher");
     book.Catalogs = j.GetNamedArray("cat").Select(value => ((BookCatalog)value.GetNumber())).ToList();
     book.Volumes = j.GetNamedArray("vols").Select((v) =>
     {
         var val = v.GetObject();
         string key = val.GetNamedString("_id");
         var value = val.GetNamedArray("chaps").Select(c => c.GetObject().GetNamedString("_id")).ToList();
         var pair = new KeyValuePair<string, List<string>>(key, value);
         return pair;
     }).ToList();
     return book;
 }
开发者ID:fuchu,项目名称:LightNovelClientWindows,代码行数:18,代码来源:LightKindomHtmlClient.cs

示例8: ResolvedActionFromJsonObject

        /// <summary>
        /// Parses and constructs a ResolvedAction instance from the given JSON data.
        /// </summary>
        /// <param name="contentJson"></param>
        /// <returns>A newly created ResolvedAction instance.</returns>
        public static ResolvedAction ResolvedActionFromJsonObject(JsonObject contentJson)
        {
            var resolvedAction = new ResolvedAction();

            var obj = contentJson.GetObject();
            var type = (int)obj.GetNamedValue(KeyType).GetNumber();
            var actionUUID = obj.GetNamedString(KeyActionUuid);
            var trigger = (int)obj.GetNamedNumber(KeyTrigger);
            var delaySeconds = JsonHelper.Optional(obj, KeyDelayTime, 0);
            var jsonContent = obj.GetNamedObject(KeyContent);
            var sendOnlyOnce = JsonHelper.OptionalBoolean(obj, KeySendOnlyOnce, false);
            var beacons = contentJson.GetNamedArray(KeyBeacons);
            var supressionTime = JsonHelper.Optional(obj, KeysupressionTime, -1);
            var reportImmediately = JsonHelper.OptionalBoolean(obj, KeyReportImmediately, false);

            // TimeFrames
            if (obj.ContainsKey(KeyTimeframes))
            {
                if (obj.GetNamedValue(KeyTimeframes).ValueType == JsonValueType.Array)
                {
                    var keyframes = obj.GetNamedArray(KeyTimeframes);

                    foreach (var frame in keyframes)
                    {
                        if (frame.ValueType == JsonValueType.Object)
                        {
                            string start = JsonHelper.OptionalString(frame.GetObject(), KeyStart);
                            string end = JsonHelper.OptionalString(frame.GetObject(), KeyEnd);
                            DateTimeOffset? startOffset = null;
                            DateTimeOffset? endOffset = null;

                            var newFrame = new Timeframe();

                            if (start.Length > 5)
                            {
                                startOffset = DateTimeOffset.Parse(start);
                            }
                            if (end.Length > 5)
                            {
                                endOffset = DateTimeOffset.Parse(end);
                            }

                            resolvedAction.Timeframes.Add(new Timeframe() { Start = startOffset, End = endOffset });
                        }
                    }
                }
            }

            foreach (JsonValue resp in beacons)
            {
                if (resp.ValueType == JsonValueType.String)
                {
                    resolvedAction.BeaconPids.Add(resp.GetString(), 1);
                }
            }

            BeaconAction action = ActionFactory.CreateBeaconAction(type, jsonContent, actionUUID);
            resolvedAction.BeaconAction = action;
            resolvedAction.EventTypeDetectedByDevice = (BeaconEventType)trigger;
            resolvedAction.Delay = delaySeconds;
            resolvedAction.SendOnlyOnce = sendOnlyOnce;
            resolvedAction.SupressionTime = supressionTime;
            resolvedAction.ReportImmediately = reportImmediately;

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

示例9: ResolveAccountBeaconId1s

        private void ResolveAccountBeaconId1s(JsonObject content)
        {
            AccountBeaconId1s.Clear();
            JsonArray responses = content.GetNamedArray(KeyAccountBeaconId1s);
            string beaconId1 = string.Empty;

            foreach (JsonValue resp in responses)
            {
                if (resp.ValueType == JsonValueType.String)
                {
                    beaconId1 = resp.GetString();
                    AccountBeaconId1s.Add(beaconId1);
                }
            }
        }
开发者ID:WombatWorks,项目名称:windows10-sdk,代码行数:15,代码来源:Layout.cs

示例10: GetHighestEntity

        private string GetHighestEntity(JsonObject json)
        {
            var entities = json.GetNamedArray("entities");
            var highestEntity = "";
            double highestEntityScore = 0;
            foreach (var jsonValue in entities)
            {
                var entity = jsonValue.GetObject();
                var score = entity.GetNamedNumber("score");
                if (!(score > highestEntityScore))
                    continue;
                highestEntityScore = score;
                highestEntity = entity.GetNamedString("entity");
            }

            return highestEntity;
        }
开发者ID:erickbp,项目名称:IoT,代码行数:17,代码来源:MainPage.xaml.cs

示例11: GetHighestInent

        private string GetHighestInent(JsonObject json)
        {
            var intents = json.GetNamedArray("intents");
            var highestIntent = "";
            double highestIntentScore = 0;
            foreach (var jsonValue in intents)
            {
                var intent = jsonValue.GetObject();
                var score = intent.GetNamedNumber("score");
                if (!(score > highestIntentScore))
                    continue;
                highestIntentScore = score;
                highestIntent = intent.GetNamedString("intent");
            }

            return highestIntent;
        }
开发者ID:erickbp,项目名称:IoT,代码行数:17,代码来源:MainPage.xaml.cs

示例12: LoadState

        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override async void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            // Allow saved page state to override the initial item to display
            if (pageState != null && pageState.ContainsKey("SelectedItem"))
            {
                navigationParameter = pageState["SelectedItem"];
            }

            String YWSID = "Bi9Fsbfon92vmD4DkkO4Fg";
            String url;
            if (navigationParameter != null && navigationParameter != "")
            {
                model = (Model)navigationParameter;
            }

            if (model != null)
            {
                url = "http://api.yelp.com/business_review_search?term=food&location=" + model.Location + "&ywsid=" + YWSID;
            }
            else 
            {
                Geolocator locator = new Geolocator();
                Geoposition geoPos = await locator.GetGeopositionAsync();
                Geocoordinate geoCoord = geoPos.Coordinate;
                url = "http://api.yelp.com/business_review_search?term=food&lat=" + geoCoord.Latitude + "&long=" + geoCoord.Longitude + "&ywsid=" + YWSID;
            }

            var httpClient = new HttpClient();
            String content = await httpClient.GetStringAsync(url);
            response = JsonObject.Parse(content);

            if (response.GetNamedArray("businesses").Count == 0)
            {
                if (model != null)
                {
                    model.error = true;
                    GoBack(this, null);
                }
                else
                {
                    this.Frame.Navigate(typeof(LocationEntryPage));
                }
            }
            else
            {
                StopLoading();
                PopulateNewRestaurant();
            }
        }
开发者ID:Hitchhikrr,项目名称:psucampapp,代码行数:58,代码来源:MainPage.xaml.cs

示例13: read

        public override Data read(JsonObject obj)
        {
            FacetGroup facetGroup = new FacetGroup();
            Facet facet = new Facet();
            try
            {
                facetGroup.GroupName = obj.GetNamedString("filter");
                JsonArray root = obj.GetNamedArray(arrayName);

                facet.readList<Facet>(root, facetGroup.Items);
            }
            catch (Exception e)
            {
                //TODO: log exception
                System.Diagnostics.Debug.WriteLine(e.Message);
            }

            return facetGroup;
        }
开发者ID:shalabi67,项目名称:Search,代码行数:19,代码来源:FacetGroup.cs

示例14: AssignMarks

        private static void AssignMarks(LtpCourse course, JsonObject marksObject)
        {
            if (marksObject.GetNamedBoolean("supported") == false)
            {
                course.InternalMarksScored = 0;
                course.TotalMarksTested = 0;
                return;
            }

            double marksScored = 0;
            JsonArray marksArray = marksObject.GetNamedArray("assessments");
            foreach (JsonValue marksValue in marksArray)
            {
                JsonObject markStubObject = marksValue.GetObject();
                string title = markStubObject.GetNamedString("title").ToUpper();
                int maxMarks = (int)markStubObject.GetNamedNumber("max_marks");
                int weightage = (int)markStubObject.GetNamedNumber("weightage");

                MarkInfo markInfo;
                if (markStubObject.GetNamedValue("scored_marks").ValueType == JsonValueType.Null)
                    markInfo = new MarkInfo(course, title, maxMarks, weightage, null, null, "");
                else
                {
                    markInfo = new MarkInfo(course, title, maxMarks, weightage,
                                    null, // currently, 'conducted date' is being skipped.
                                    markStubObject.GetNamedNumber("scored_marks"),
                                    markStubObject.GetNamedString("status").ToUpper());

                    marksScored += (double)markInfo.WeightedMarks;
                    course.TotalMarksTested += markInfo.Weightage;
                }
                course.AddMarkInfo(markInfo);
            }

            course.InternalMarksScored = Math.Round(marksScored, 2);
        }
开发者ID:gitter-badger,项目名称:VITacademics_Windows,代码行数:36,代码来源:JsonParser.cs

示例15: 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


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