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


C# Linq.JArray类代码示例

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


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

示例1: ItemListStatic

 public ItemListStatic(JObject basicO,
     JObject dataO,
     JArray groupsA,
     JArray treeA,
     string type,
     string version,
     JObject originalObject)
 {
     data = new Dictionary<string, ItemStatic>();
     groups = new List<GroupStatic>();
     tree = new List<ItemTreeStatic>();
     if (basicO != null)
     {
         basic = HelperMethods.LoadBasicDataStatic(basicO);
     }
     if (dataO != null)
     {
         LoadData(dataO.ToString());
     }
     if (groupsA != null)
     {
         LoadGroups(groupsA);
     }
     if (treeA != null)
     {
         LoadTree(treeA);
     }
     this.type = type;
     this.version = version;
     this.originalObject = originalObject;
 }
开发者ID:mattregul,项目名称:CreepScore,代码行数:31,代码来源:ItemListStatic.cs

示例2: CreateEDDNMessage

        public JObject CreateEDDNMessage(JournalFSDJump journal)
        {
            if (!journal.HasCoordinate)
                return null;

            JObject msg = new JObject();

            msg["header"] = Header();
            msg["$schemaRef"] = "http://schemas.elite-markets.net/eddn/journal/1/test";

            JObject message = new JObject();

            message["StarSystem"] = journal.StarSystem;
            message["Government"] = journal.Government;
            message["timestamp"] = journal.EventTimeUTC.ToString("yyyy-MM-ddTHH:mm:ssZ");
            message["Faction"] = journal.Faction;
            message["Allegiance"] = journal.Allegiance;
            message["StarPos"] = new JArray(new float[] { journal.StarPos.X, journal.StarPos.Y, journal.StarPos.Z });
            message["Security"] = journal.Security;
            message["event"] = journal.EventTypeStr;
            message["Economy"] = journal.Economy;

            msg["message"] = message;
            return msg;
        }
开发者ID:amatos,项目名称:EDDiscovery,代码行数:25,代码来源:EDDNClass.cs

示例3: AfterSeleniumTestScenario

        public static void AfterSeleniumTestScenario()
        {
            var time = DateTime.UtcNow;

            var currentFeature = (JObject) FeatureContext.Current["currentFeature"];
            var scenarios = (JArray) currentFeature["scenarios"];
            var scenario = new JObject();
            scenario["title"] = ScenarioContext.Current.ScenarioInfo.Title;
            scenario["startTime"] = FeatureContext.Current["time"].ToString();
            scenario["endTime"] = time.ToString();
            scenario["tags"] = new JArray(ScenarioContext.Current.ScenarioInfo.Tags);

            var err = ScenarioContext.Current.TestError;
            if (err != null)
            {
                var error = new JObject();
                error["message"] = ScenarioContext.Current.TestError.Message;
                error["stackTrace"] = ScenarioContext.Current.TestError.StackTrace;
                scenario["error"] = error;
                scenario["status"] = "error";
            }
            else {
                scenario["status"] = "ok";
            }
            scenarios.Add(scenario);
        }
开发者ID:agentmilindu,项目名称:CodeSpec,代码行数:26,代码来源:FeatureBase.cs

示例4: Get

        public IHttpActionResult Get(string name)
        {
            var json = string.Empty;
            var account = CloudStorageAccount.Parse(Config.Get("DeepStorage.OutputConnectionString"));
            var blobClient = account.CreateCloudBlobClient();
            var container = blobClient.GetContainerReference(Config.Get("DeepStorage.HdpContainerName"));

            var prefix = string.Format("{0}.json/part-r-", name);
            var matchingBlobs = container.ListBlobs(prefix, true);
            foreach (var part in matchingBlobs.OfType<CloudBlockBlob>())
            {
                json += part.DownloadText() + Environment.NewLine;
            }

            var outputArray = new JArray();
            foreach (var line in json.Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries))
            {
                dynamic raw = JObject.Parse(line);
                var formatted = new JArray();
                formatted.Add((string)raw.eventName);
                formatted.Add((long)raw.count);
                outputArray.Add(formatted);
            }

            return Ok(outputArray);
        }
开发者ID:smartpcr,项目名称:bigdata2,代码行数:26,代码来源:QueryOutputController.cs

示例5: AddToSelf

    public void AddToSelf()
    {
      JArray a = new JArray();
      a.Add(a);

      Assert.IsFalse(ReferenceEquals(a[0], a));
    }
开发者ID:nagyist,项目名称:Newtonsoft.Json,代码行数:7,代码来源:JArrayTests.cs

示例6: WriteJson

        /// <summary>
        ///     Writes the JSON representation of the object.
        /// </summary>
        /// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter" /> to write to.</param>
        /// <param name="value">The value.</param>
        /// <param name="serializer">The calling serializer.</param>
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var coordinateElements = value as List<IPosition>;
            if (coordinateElements != null && coordinateElements.Count > 0)
            {
                var coordinateArray = new JArray();

                foreach (var position in coordinateElements)
                {
                    // TODO: position types should expose a double[] coordinates property that can be used to write values 
                    var coordinates = (GeographicPosition)position;
                    var coordinateElement = new JArray(coordinates.Longitude, coordinates.Latitude);
                    if (coordinates.Altitude.HasValue)
                    {
                        coordinateElement = new JArray(coordinates.Longitude, coordinates.Latitude, coordinates.Altitude);
                    }

                    coordinateArray.Add(coordinateElement);
                }

                serializer.Serialize(writer, coordinateArray);
            }
            else
            {
                serializer.Serialize(writer, value);
            }
        }
开发者ID:tobiashoeft,项目名称:GeoJSON.Net,代码行数:33,代码来源:LineStringConverter.cs

示例7: GetPropertyEditors

 /// <summary>
 /// Parse the property editors from the json array
 /// </summary>
 /// <param name="jsonEditors"></param>
 /// <returns></returns>
 internal static IEnumerable<PropertyEditor> GetPropertyEditors(JArray jsonEditors)
 {
     return JsonConvert.DeserializeObject<IEnumerable<PropertyEditor>>(
         jsonEditors.ToString(), 
         new PropertyEditorConverter(),
         new PreValueFieldConverter());
 }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:12,代码来源:ManifestParser.cs

示例8: Diff

 public static JArray Diff(JArray source, JArray target, out bool changed, bool nullOnRemoved = false)
 {
     changed = source.Count != target.Count;
     var diffs = new JToken[target.Count];
     var commonLen = Math.Min(diffs.Length, source.Count);
     for (int i = 0; i < commonLen; i++)
     {
         if (target[i].Type == JTokenType.Object && source[i].Type == JTokenType.Object)
         {
             var subchanged = false;
             diffs[i] = Diff((JObject)source[i], (JObject)target[i], out subchanged, nullOnRemoved);
             if (subchanged) changed = true;
         }
         else if (target[i].Type == JTokenType.Array && source[i].Type == JTokenType.Array)
         {
             var subchanged = false;
             diffs[i] = Diff((JArray)source[i], (JArray)target[i], out subchanged, nullOnRemoved);
             if (subchanged) changed = true;
         }
         else
         {
             diffs[i] = target[i];
             if (!JToken.DeepEquals(source[i], target[i]))
                 changed = true;
         }
     }
     for (int i = commonLen; i < diffs.Length; i++)
     {
         diffs[i] = target[i];
         changed = true;
     }
     return new JArray(diffs);
 }
开发者ID:holajan,项目名称:dotvvm,代码行数:33,代码来源:JsonUtils.cs

示例9: LoadMemberList

 /// <summary>
 /// Loads member list
 /// </summary>
 /// <param name="a">json list of members</param>
 void LoadMemberList(JArray a)
 {
     for (int i = 0; i < a.Count; i++)
     {
         memberList.Add(new TeamMemberInfo((long)a[i]["inviteDate"], (long?)a[i]["joinDate"], (long)a[i]["playerId"], (string)a[i]["status"]));
     }
 }
开发者ID:mattregul,项目名称:CreepScore,代码行数:11,代码来源:Roster.cs

示例10: Button_Click

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                dynamic jsonConfig = new JObject();

                var sizeX = int.Parse(SizeXBox.Text);
                jsonConfig.sizeX = sizeX;
                var sizeY = int.Parse(SizeYBox.Text);
                jsonConfig.sizeY = sizeY;

                var markerIds = new JArray();

                var startId = int.Parse(MarkerIdsBox.Text);
                for (int i = 0; i < sizeX * sizeY; i++)
                {
                    markerIds.Add(startId + i);
                }

                jsonConfig.markerIds = markerIds;
                jsonConfig.imgFilename = ImgFilenameBox.Text;
                jsonConfig.configFilename = ConfigFilenameBox.Text;
                jsonConfig.dictionaryName = ArucoDictionaries.SelectedItem as string;
                jsonConfig.pixelSize = int.Parse(PixelSizeBox.Text);
                jsonConfig.interMarkerDistance = float.Parse(InterMarkerDistanceBox.Text);

                ImageProcessing.GenerateMarkerMap(jsonConfig.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
        }
开发者ID:SebiH,项目名称:BachelorProject,代码行数:34,代码来源:MarkerMapGenerator.xaml.cs

示例11: AnalyzeScores

        public string AnalyzeScores(string localizationCode, string messages)
        {
            JsonSerializer serializer = new JsonSerializer();
            TextReader reader = new StringReader(messages);
            JArray jArray = (JArray)serializer.Deserialize(reader, typeof(JArray));

            JArray scoreResults = new JArray();

            for (int index = 0; index < jArray.Count; index++ )
            {
                JToken entry = jArray[index];
                IMessage message = new Message
                {
                     Content = new StringBuilder( entry["text"].ToString()),
                     Metadata = new StringBuilder(entry.ToString())
                };

                double score =  this.AnalyzeScore(localizationCode, message);

                entry["Score"] = score;

                scoreResults.Add(entry);
            }

            TextWriter writer = new StringWriter();

            serializer.Serialize(writer, scoreResults);

            string mergedJsonResult = writer.ToString();

            return mergedJsonResult;
        }
开发者ID:evelasco85,项目名称:MEQS,代码行数:32,代码来源:ExecutionEngine.cs

示例12: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            if (context.Session["Authentication"] == null)
                throw new Exception("Ошибка обновления");

            int ShopId = Convert.ToInt32(context.Session["ShopId"]);
            int ArticleId = Convert.ToInt32(context.Request["ArticleId"]);

            var dsStatistic = new dsStatistic();
            (new DataSets.dsStatisticTableAdapters.taSalesHistory()).Fill
                (dsStatistic.tbSalesHistory, ShopId, ArticleId);

            var JHistory = new JArray();
            foreach (dsStatistic.tbSalesHistoryRow rw in dsStatistic.tbSalesHistory)
                JHistory.Add(new JObject(
                    new JProperty("Дата_продажи",rw.Дата_продажи),
                    new JProperty("Номер_чека", rw.Номер_чека),
                    new JProperty("Количество", rw.Количество),
                    new JProperty("ПрИнфо", rw.ПрИнфо),
                    new JProperty("Инфо", rw.Инфо)
                    ));

            var JObject = new JObject(
                new JProperty("Код_артикула", ArticleId),
                new JProperty("История", JHistory));

            context.Response.ContentType = "application/json";
            context.Response.Write(JObject.ToString());
        }
开发者ID:PeletonSoft,项目名称:WebProjects,代码行数:29,代码来源:Content.ashx.cs

示例13: GetProductIDs

        public DocumentSearchResponse GetProductIDs(JArray relatedItems)
        {
            // Execute search to find all the related products
            try
            {
                SearchParameters sp = new SearchParameters()
                {
                    SearchMode = SearchMode.Any,
                    // Limit results
                    Select = new List<String>() {"product_id","brand_name","product_name","srp","net_weight","recyclable_package",
                        "low_fat","units_per_case","product_subcategory","product_category","product_department","url", "recommendations"},
                };

                // Filter based on the product ID's
                string productIdFilter = null;
                foreach (var item in relatedItems)
                {
                    productIdFilter += "product_id eq '" + item.ToString() + "' or ";
                }
                productIdFilter = productIdFilter.Substring(0, productIdFilter.Length - 4);
                sp.Filter = productIdFilter;

                return _indexClient.Documents.Search("*", sp);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error querying index: {0}\r\n", ex.Message.ToString());
            }
            return null;
        }
开发者ID:HeidiSteen,项目名称:AzureSearchDemos,代码行数:30,代码来源:Search.cs

示例14: Prep

 public static List<SysObj> Prep(JArray list)
 {
     SysObj sys = null;
     var setting = new JsonSerializerSettings();
     setting.NullValueHandling = NullValueHandling.Ignore;
     List<SysObj> systems = new List<SysObj>();
     List<SysObj> result = new List<SysObj>();
     for (int cnt = 0; cnt < list.Count; cnt++)
     {
         sys = JsonConvert.DeserializeObject<SysObj>(list[cnt].ToString(), setting);
         if (string.IsNullOrEmpty(sys.security))
             sys.security = "None";
         if (string.IsNullOrEmpty(sys.power))
             sys.power = "None";
         if (string.IsNullOrEmpty(sys.primary_economy))
             sys.primary_economy = "None";
         if (string.IsNullOrEmpty(sys.simbad_ref))
             sys.simbad_ref = "";
         if (string.IsNullOrEmpty(sys.power_state))
             sys.power_state = "None";
         if (string.IsNullOrEmpty(sys.state))
             sys.state = "None";
         if (string.IsNullOrEmpty(sys.allegiance))
             sys.allegiance = "None";
         if (string.IsNullOrEmpty(sys.government))
             sys.government = "None";
         if (string.IsNullOrEmpty(sys.faction))
             sys.faction = "None";
         if (sys.needs_permit.Equals(null))
             sys.needs_permit = 0;
         systems.Add(sys);
     }
     return systems;
 }
开发者ID:urmamasllama,项目名称:EDAdvancedSearch,代码行数:34,代码来源:EDS.cs

示例15: PlayerStatsSummaryList

 public PlayerStatsSummaryList(JArray playerStatSummariesA, long summonerId, CreepScore.Season season)
 {
     playerStatSummaries = new List<PlayerStatsSummary>();
     LoadPlayerStatSummaries(playerStatSummariesA);
     this.summonerId = summonerId;
     this.season = season;
 }
开发者ID:mattregul,项目名称:CreepScore,代码行数:7,代码来源:PlayerStatsSummaryList.cs


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