本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例5: AddToSelf
public void AddToSelf()
{
JArray a = new JArray();
a.Add(a);
Assert.IsFalse(ReferenceEquals(a[0], a));
}
示例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);
}
}
示例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());
}
示例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);
}
示例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"]));
}
}
示例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);
}
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例15: PlayerStatsSummaryList
public PlayerStatsSummaryList(JArray playerStatSummariesA, long summonerId, CreepScore.Season season)
{
playerStatSummaries = new List<PlayerStatsSummary>();
LoadPlayerStatSummaries(playerStatSummariesA);
this.summonerId = summonerId;
this.season = season;
}