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


C# JArray.Children方法代码示例

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


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

示例1: BuildList

 private List<ToDoItem> BuildList(List<ToDoItem> todoItems, JArray y)
 {
     foreach (var item in y.Children())
     {
         var itemProperties = item.Children<JProperty>();
         var element = itemProperties.FirstOrDefault(xx => xx.Name == "values");
         JProperty index = itemProperties.FirstOrDefault(xxx => xxx.Name == "index");
         JToken values = element.Value;
         var stringValues = from stringValue in values select stringValue;
         foreach (JToken thing in stringValues)
         {
             IEnumerable<string> rowValues = thing.Values<string>();
             string[] stringArray = rowValues.Cast<string>().ToArray();
             try
             {
                 ToDoItem todoItem = new ToDoItem(
                      Convert.ToInt32(index.Value),
                      stringArray[1],
                      stringArray[3],
                      stringArray[4],
                      stringArray[2],
                      stringArray[5],
                      stringArray[6],
                 stringArray[7]);
                 todoItems.Add(todoItem);
             }
             catch (FormatException f)
             {
                 Console.WriteLine(f.Message);
             }
         }
     }
     return todoItems;
 }
开发者ID:OneBitSoftware,项目名称:TrainingContent,代码行数:34,代码来源:ExcelAPIHelper.cs

示例2: restoreArray

 /// <summary>
 /// Создать список объектов из json массива
 /// </summary>
 /// <param name="array"></param>
 /// <returns></returns>
 public static List<AbstractStorable> restoreArray(JArray array)
 {
     List<AbstractStorable> list = new List<AbstractStorable>();
     foreach (JObject obj in array.Children<JObject>())
     {
         list.Add(AbstractStorable.newInstance(obj));
     }
     return list;
 }
开发者ID:Nizhegorodtsev,项目名称:Diplom.NET,代码行数:14,代码来源:JsonUtils.cs

示例3: restoreMatrix

 /// <summary>
 /// Восстановить матрицу
 /// </summary>
 /// <param name="array"></param>
 /// <returns></returns>
 public static double[][] restoreMatrix(JArray array)
 {
     double[][] matrix = new double[array.Count][];
     int i = 0;
     foreach (JArray obj in array.Children<JArray>())
     {
         matrix[i] = restoreVector(obj);
         i++;
     }
     return matrix;
 }
开发者ID:Nizhegorodtsev,项目名称:Diplom.NET,代码行数:16,代码来源:JsonUtils.cs

示例4: Main

        static void Main(string[] args)
        {
            string query = "select count(id) Enero from [apiDashboard].[dbo].[maFlow]   where DATEPART(month, payDatetime) = 01; select count(id) Febrero from [apiDashboard].[dbo].[maFlow]   where DATEPART(month, payDatetime) = 02";

            var client = new RestClient("http://localhost:64412/apiV1/");
            // client.Authenticator = new HttpBasicAuthenticator(username, password);

            var request = new RestRequest(string.Format("select?query={0}", query.Trim()), Method.GET);

            request.AddHeader("Accept", "application/json");
            request.AddHeader("CnnString", "RGF0YSBTb3VyY2U9Llxtc3NxbDIwMTQ7SW5pdGlhbCBDYXRhbG9nPWFwaURhc2hib2FyZDtQZXJzaXN0IFNlY3VyaXR5IEluZm89VHJ1ZTtVc2VyIElEPXNhO1Bhc3N3b3JkPWFz");
            request.AddHeader("Provider", "sqlserver");

            try
            {
                RestResponse response = client.Execute(request) as RestResponse;

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    dynamic data = JValue.Parse(response.Content);

                    if (data.REST_Service.Status_code.ToString() == "1")
                    {
                        foreach (dynamic item in data.Response)
                        {
                            Console.WriteLine("Command : {0}", item.Command.ToString());
                            JArray result = new JArray(item.Result);

                            foreach (JObject content in result.Children<JObject>())
                            {
                                foreach (JProperty prop in content.Properties())
                                {
                                    Console.WriteLine("{0} : {1}", prop.Name.ToString().Trim(), prop.Value.ToString().Trim());
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new Exception(data.REST_Service.Message.ToString());
                    }
                }
                else
                {
                    throw new Exception(response.StatusDescription);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(string.Format("Ocurrió un error [ {0} ]", ex.Message));
            }

            Console.ReadKey();
        }
开发者ID:xmalmorthen,项目名称:apiDasboard,代码行数:54,代码来源:Program.cs

示例5: Load

        public static PatchDocument Load(JArray document) {
            var root = new PatchDocument();

            if (document == null)
                return root;

            foreach (var jOperation in document.Children().Cast<JObject>()) {
                var op = Operation.Build(jOperation);
                root.AddOperation(op);
            }

            return root;
        }
开发者ID:exceptionless,项目名称:Foundatio.Repositories,代码行数:13,代码来源:PatchDocument.cs

示例6: MapArray

        /// <summary>
        /// Populates <paramref name="target"/> with values from <paramref name="source"/> and <paramref name="response"/>
        /// as defined by <paramref name="fieldMap"/>. It also returns a new <see cref="Newtonsoft.Json.Linq.JArray"/> with mapped values.
        /// </summary>
        /// <param name="source">The response body from which to get values.</param>
        /// <param name="response">The response object from which to get values.</param>
        /// <param name="fieldMap">A definition of field mappings.</param>
        /// <param name="target">The target object to populate with mapped key/values.</param>
        /// <param name="maxResults">The maximum number of results to return.</param>
        /// <returns>A new <see cref="Newtonsoft.Json.Linq.JArray"/> with mapped values.</returns>
        public JArray MapArray(JArray source, HttpWebResponse response, MappedFieldList fieldMap, ApplicationData target, int? maxResults = null)
        {
            int max = maxResults ?? int.MaxValue;
            JArray outArray = new JArray();
            IEnumerator<JObject> enumerator = source.Children<JObject>().GetEnumerator();
            int i = 0;
            while (enumerator.MoveNext() && i < max)
            {
                outArray.Add(this.MapObject(enumerator.Current, response, fieldMap, target));
                i++;
            }

            return outArray;
        }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:24,代码来源:HttpEndpointResponseMapper.cs

示例7: GetFoxBoxscoreUrl

        public static string GetFoxBoxscoreUrl(JArray scheduleJson, int awayTeamId, int homeTeamId)
        {
            var boxscoreUrl = string.Empty;

            foreach (var game in scheduleJson.Children())
            {
                if (game["AwayTeamId"].Value<int>() == awayTeamId && game["HomeTeamId"].Value<int>() == homeTeamId)
                {
                    var linksObj = game["Links"];
                    boxscoreUrl = linksObj["boxscore"].Value<string>();
                    break;
                }
            }

            return boxscoreUrl;
        }
开发者ID:mpnieland,项目名称:NPGGFFL,代码行数:16,代码来源:FoxSportsScraper.cs

示例8: MockedResultSet

        public MockedResultSet(JArray data, Func<JObject, bool> predicate = null, IEnumerable<JProperty> schema = null)
        {
            if (data == null)
            {
                Data = new JObject[0];
            }
            else
            {
                Data = data.Children().Cast<JObject>();
                if (predicate != null) Data = Data.Where(predicate);
            }

            if (schema == null && Data != null)
            {
                var list = Data.ToList();
                var first = list.FirstOrDefault();
                if (first != null) schema = first.Properties();
                Data = list;
            }
            Schema = schema;
        }
开发者ID:Bikeman868,项目名称:Prius,代码行数:21,代码来源:MockedResultSet.cs

示例9: ForecastsDataMapper

        public List<Forecast> ForecastsDataMapper(JObject jsonObject)
        {
            List<Forecast> forecasts = new List<Forecast>();

            JArray dataArray = new JArray(jsonObject["data"].Children());

            foreach (var item in dataArray.Children())
            {
                JObject itemJSON = JObject.Parse(item.ToString());

                Forecast forecast = new Forecast();

                forecast.ForecastDate = FieldMapperDateTime(itemJSON, "time");
                forecast.ForecastDateDisplay = forecast.ForecastDate.ToShortDateString();
                forecast.ForecastWeather = WeatherDataMapper(itemJSON, "summary", "temperatureMax");

                forecasts.Add(forecast);
            }

            return forecasts;
        }
开发者ID:tara-wilkinson,项目名称:weather-dashboard,代码行数:21,代码来源:ForecastIOWeatherRepository.cs

示例10: ForecastsDataMapper

        public List<Forecast> ForecastsDataMapper(JObject jsonObject)
        {
            List<Forecast> forecasts = new List<Forecast>();

            JArray dataArray = new JArray(jsonObject["forecastday"].Children());

            foreach (var item in dataArray.Children())
            {
                JObject itemJSON = JObject.Parse(item.ToString());

                Forecast forecast = new Forecast();

                forecast.ForecastDate = FieldMapperDateTime(JObject.Parse(itemJSON["date"].ToString()), "epoch");
                forecast.ForecastDateDisplay = forecast.ForecastDate.ToShortDateString();
                forecast.ForecastWeather = WeatherDataMapper(itemJSON, "conditions", "high", "fahrenheit");

                forecasts.Add(forecast);
            }

            return forecasts;
        }
开发者ID:tara-wilkinson,项目名称:weather-dashboard,代码行数:21,代码来源:WundergroundWeatherRepository.cs

示例11: ReportInvalidStepValues

        private void ReportInvalidStepValues(
            AnnotatedCodeLocation[] locations,
            JArray annotatedCodeLocationArray,
            string annotatedCodeLocationsPointer)
        {
            JObject[] annotatedCodeLocationObjects = annotatedCodeLocationArray.Children<JObject>().ToArray();

            for (int i = 0; i < locations.Length; ++i)
            {
                // Only report "invalid step value" for locations that actually specify
                // the "step" property (the value of the Step property in the object
                // model will be 0 for such steps, which is never valid), because we
                // already reported the missing "step" properties.
                if (LocationHasStep(annotatedCodeLocationObjects[i]) &&
                    locations[i].Step != i + 1)
                {
                    string invalidStepPointer = annotatedCodeLocationsPointer
                        .AtIndex(i).AtProperty(SarifPropertyName.Step);

                    LogResult(
                        invalidStepPointer,
                        nameof(RuleResources.SARIF009_InvalidStepValue),
                        (i + 1).ToInvariantString(),
                        (locations[i].Step).ToInvariantString());
                }
            }
        }
开发者ID:Microsoft,项目名称:sarif-sdk,代码行数:27,代码来源:StepValuesMustFormOneBasedSequence.cs

示例12: GetSpecifiedPropertiesFromFeedPayload

        /// <summary>
        /// Get specified properties from an feed payload.
        /// </summary>
        /// <param name="feed">A feed.</param>
        /// <param name="elementName">An element name which is expected to get.</param>
        /// <returns>Returns a list of properties.</returns>
        public static List<JProperty> GetSpecifiedPropertiesFromFeedPayload(JArray feed, string elementName)
        {
            if (feed == null || elementName == null || elementName == string.Empty)
            {
                return props;
            }

            if (feed != null && feed.Type == JTokenType.Array)
            {
                foreach (JObject entry in feed.Children())
                {
                    props = GetSpecifiedPropertiesFromEntryPayload(entry, elementName);
                }
            }

            return props;
        }
开发者ID:congysu,项目名称:ValidationTool,代码行数:23,代码来源:JsonParserHelper.cs

示例13: GetStringFromArray

        private static string GetStringFromArray(JArray array)
        {
            if (array.Count == 0)
                return "";

            bool isOneLine =
                array.Children()
                     .All(t => t.Type == JTokenType.Integer ||
                               t.Type == JTokenType.Float ||
                               t.Type == JTokenType.Boolean);
            if (isOneLine)
            {
                return string.Join(", ",
                                   array.Children().Select(c => c.ToString(Formatting.None)).ToArray());
            }
            else
            {
                return string.Join("\n",
                                   array.Children().Select(c => c.ToString(Formatting.None)).ToArray());
            }
        }
开发者ID:SaladLab,项目名称:ExcelJsonTable,代码行数:21,代码来源:DataTransform.cs

示例14: translateToDisplayName

        public JArray translateToDisplayName(JArray array, string type)
        {
            var displayNames = crmService.GetAttributeDisplayName(type);
            var contactsWithDisplayNames = new JArray();

            foreach (var contact in array.Children<JObject>())
            {
                var newContact = new JObject();
                foreach (var keyValue in contact.Properties())
                {
                    if (displayNames.ContainsKey(keyValue.Name.ToString().ToLower()))
                    {
                        string displayName;
                        displayNames.TryGetValue(keyValue.Name.ToString().ToLower(), out displayName);

                        if (newContact.Property(displayName) == null)
                        {
                            newContact.Add(displayName, keyValue.Value);
                        }
                        else
                        {
                            newContact.Add(displayName + " 2", keyValue.Value);
                        }

                    }
                }
                contactsWithDisplayNames.Add(newContact);
            }

            return contactsWithDisplayNames;
        }
开发者ID:SteffeKeff,项目名称:DynamicsIntegration,代码行数:31,代码来源:CrmApiHelper.cs

示例15: MergeTemplate

 /// <summary>
 /// Merge zweier Arrays
 /// </summary>
 /// <param name="iTarget"></param>
 /// <param name="iTemplate"></param>
 private void MergeTemplate(JArray iTarget, JArray iTemplate) {
     JsonMergeSettings lMergeSettings = new JsonMergeSettings();
     lMergeSettings.MergeArrayHandling = MergeArrayHandling.Union;
     if (iTemplate.First.Type == JTokenType.Array) {
         for (int i = 0; i < iTemplate.Count && i < iTarget.Count; i++) {
             //(iTarget[i] as JArray).Merge(iTemplate[i], lMergeSettings);
             //iTemplate[i].Remove();
             (iTemplate[i] as JArray).Merge(iTarget[i], lMergeSettings);
             iTarget[i].Remove();
         }
     }
     //iTarget.Merge(iTemplate, lMergeSettings);
     iTemplate.Merge(iTarget, lMergeSettings);
     iTarget.RemoveAll();
     iTarget.Add(iTemplate.Children());
 }
开发者ID:ivan73,项目名称:json,代码行数:21,代码来源:MergeTemplate.cs


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