本文整理汇总了C#中Newtonsoft.Json.JsonWriter.WriteEndArray方法的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter.WriteEndArray方法的具体用法?C# JsonWriter.WriteEndArray怎么用?C# JsonWriter.WriteEndArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.WriteEndArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var representation = value as Representation;
if (representation != null)
representation.RepopulateHyperMedia();
var list = (IRepresentationList)value;
writer.WriteStartObject();
writer.WritePropertyName("_links");
serializer.Serialize(writer, list.Links);
writer.WritePropertyName("_embedded");
writer.WriteStartObject();
writer.WritePropertyName(list.Rel);
writer.WriteStartArray();
foreach (Representation halResource in list)
{
serializer.Serialize(writer, halResource);
}
writer.WriteEndArray();
writer.WriteEndObject();
var listType = list.GetType();
var propertyInfos = typeof(RepresentationList<>).GetProperties().Select(p => p.Name);
foreach (var property in listType.GetProperties().Where(p => !propertyInfos.Contains(p.Name)))
{
writer.WritePropertyName(property.Name.ToLower());
serializer.Serialize(writer, property.GetValue(value, null));
}
writer.WriteEndObject();
}
示例2: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var marker = value as Indices;
if (marker == null)
{
writer.WriteNull();
return;
}
marker.Match(
all =>
{
writer.WriteStartArray();
writer.WriteValue("_all");
writer.WriteEndArray();
},
many =>
{
var settings = serializer.GetConnectionSettings();
writer.WriteStartArray();
foreach (var m in many.Indices.Cast<IUrlParameter>())
writer.WriteValue(m.GetString(settings));
writer.WriteEndArray();
}
);
}
示例3: FormatJson
public void FormatJson(ref JsonWriter writer)
{
writer.WriteStartObject();
writer.WritePropertyName("type");
writer.WriteValue("table");
writer.WritePropertyName("headers");
writer.WriteStartArray();
foreach(var header in this.headers.ToArray())
{
writer.WriteValue(header);
}
writer.WriteEndArray();
writer.WritePropertyName("rows");
writer.WriteStartArray();
foreach (var row in this.rows.ToArray())
{
writer.WriteStartArray();
foreach( var field in row)
{
writer.WriteValue(field);
}
writer.WriteEndArray();
}
writer.WriteEndArray();
writer.WriteEndObject();
}
示例4: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
BoolQuery term = (BoolQuery)value;
if (term != null)
{
writer.WriteStartObject();
writer.WritePropertyName("bool");
writer.WriteStartObject();
bool pre = false;
if(term.MustQueries!=null&&term.MustQueries.Count>0)
{
writer.WritePropertyName("must");
writer.WriteStartArray();
foreach (var VARIABLE in term.MustQueries)
{
serializer.Serialize(writer, VARIABLE);
}
writer.WriteEndArray();
}
if (term.MustNotQueries != null&&term.MustNotQueries.Count>0)
{
writer.WritePropertyName("must_not");
writer.WriteStartArray();
foreach (var VARIABLE in term.MustNotQueries)
{
serializer.Serialize(writer, VARIABLE);
}
writer.WriteEndArray();
}
if (term.ShouldQueries !=null&& term.ShouldQueries.Count > 0)
{
writer.WritePropertyName("should");
writer.WriteStartArray();
foreach (var shouldQuery in term.ShouldQueries)
{
serializer.Serialize(writer,shouldQuery);
}
writer.WriteEndArray();
}
if (Math.Abs(term.Boost - 1.0) > 0)
{
writer.WritePropertyName("boost");
writer.WriteValue(term.Boost);
}
if (term.DisableCoord)
{
writer.WritePropertyName("disable_coord");
writer.WriteValue(term.DisableCoord);
}
if (term.MinimumNumberShouldMatch != 1)
{
writer.WritePropertyName("minimum_number_should_match");
writer.WriteValue(term.MinimumNumberShouldMatch);
}
writer.WriteEndObject();
writer.WriteEndObject();
}
}
示例5: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var rt = (ResultTable)value;
writer.WriteStartObject();
writer.WritePropertyName("entityColumn");
writer.WriteValue(rt.EntityColumn?.Name);
writer.WritePropertyName("columns");
serializer.Serialize(writer, rt.Columns.Select(c => c.Column.Token.FullKey()).ToList());
writer.WritePropertyName("pagination");
serializer.Serialize(writer, new PaginationTS(rt.Pagination));
writer.WritePropertyName("totalElements");
writer.WriteValue(rt.TotalElements);
writer.WritePropertyName("rows");
writer.WriteStartArray();
foreach (var row in rt.Rows)
{
writer.WriteStartObject();
if (rt.EntityColumn != null)
{
writer.WritePropertyName("entity");
serializer.Serialize(writer, row.Entity);
}
writer.WritePropertyName("columns");
writer.WriteStartArray();
foreach (var column in rt.Columns)
{
using (JsonSerializerExtensions.SetCurrentPropertyRoute(column.Column.Token.GetPropertyRoute()))
{
serializer.Serialize(writer, row[column]);
}
}
writer.WriteEndArray();
writer.WriteEndObject();
}
writer.WriteEndArray();
writer.WriteEndObject();
}
示例6: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var extent = (Extent)value;
writer.WriteStartArray();
writer.WriteStartArray();
writer.WriteValue(extent.X1);
writer.WriteValue(extent.Y1);
writer.WriteEndArray();
writer.WriteStartArray();
writer.WriteValue(extent.X2);
writer.WriteValue(extent.Y2);
writer.WriteEndArray();
writer.WriteEndArray();
}
示例7: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var list = value as IList;
writer.WriteStartArray();
if (list == null || list.Count == 0)
{
foreach (var item in list)
{
writer.WriteStartObject();
if (value != null)
{
var type = value.GetType();
var name = type.Name;
var attribute = type.GetCustomAttributes(typeof(JsonWrapPropertyAttribute), true).FirstOrDefault() as JsonWrapPropertyAttribute;
if (attribute != null)
{
name = attribute.WrapName;
}
writer.WritePropertyName(name);
serializer.Serialize(writer, value);
}
writer.WriteEndObject();
}
}
writer.WriteEndArray();
}
示例8: WriteJson
public override JsonWriter WriteJson(JsonWriter writer)
{
if(Filters.Count > 0)
{
writer.WritePropertyName("inputs");
writer.WriteStartObject();
writer.WritePropertyName("bucket");
writer.WriteValue(_bucket);
writer.WritePropertyName("key_filters");
writer.WriteStartArray();
Filters.ForEach(f => writer.WriteRawValue(f.ToJsonString()));
writer.WriteEndArray();
writer.WriteEndObject();
}
else
{
writer.WritePropertyName("inputs");
writer.WriteValue(_bucket);
}
return writer;
}
示例9: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var links = new HashSet<Link>((IList<Link>)value, Link.EqualityComparer);
var lookup = links.ToLookup(l => l.Rel);
if (lookup.Count == 0)
return;
writer.WriteStartObject();
foreach (var rel in lookup)
{
var count = rel.Count();
writer.WritePropertyName(rel.Key);
if ((count > 1) || (rel.Key == Link.RelForCuries))
writer.WriteStartArray();
foreach (var link in rel)
WriteLink(writer, link);
if ((count > 1) || (rel.Key == Link.RelForCuries))
writer.WriteEndArray();
}
writer.WriteEndObject();
}
示例10: WriteJson
/// <summary>
/// Writes the Object to JSON
/// </summary>
/// <param name="writer">A JSON Writer object</param>
/// <param name="value">Object to be converted</param>
/// <param name="serializer">JSON Serializer object instance</param>
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
// We need a custom writer for char arrays, such as are used with SendKeys.
// JSON.NET does not properly handle converting unicode characters to \uxxxx.
writer.WriteStartArray();
char[] arrayObject = value as char[];
if (arrayObject != null)
{
foreach (char currentChar in arrayObject)
{
int codepoint = Convert.ToInt32(currentChar);
if ((codepoint >= 32) && (codepoint <= 126))
{
writer.WriteValue(currentChar);
}
else
{
string charRepresentation = "\\u" + Convert.ToString(codepoint, 16).PadLeft(4, '0');
writer.WriteRawValue("\"" + charRepresentation + "\"");
}
}
}
writer.WriteEndArray();
}
示例11: WriteJson
public override void WriteJson(JsonWriter __writer, object __value, JsonSerializer __serializer)
{
var __对象 = (M接收事件)__value;
__writer.WriteStartObject();
__writer.WritePropertyName("对象名称");
__writer.WriteValue(__对象.对象名称);
__writer.WritePropertyName("事件名称");
__writer.WriteValue(__对象.事件名称);
__writer.WritePropertyName("实参列表");
__writer.WriteStartArray();
if (__对象.实参列表 != null)
{
foreach (var __kv in __对象.实参列表)
{
__writer.WriteStartObject();
__writer.WritePropertyName("名称");
__writer.WriteValue(__kv.名称);
__writer.WritePropertyName("值");
if (__kv.值.TrimStart().StartsWith("{") || __kv.值.TrimStart().StartsWith("["))
{
__writer.WriteRawValue(__kv.值);
}
else
{
__writer.WriteValue(__kv.值);
}
__writer.WriteEndObject();
}
}
__writer.WriteEndArray();
__writer.WriteEndObject();
}
示例12: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value == null)
{
writer.WriteNull();
}
else
{
var notifications = (ClientNotifications)value;
writer.WriteStartArray();
foreach (var p in notifications)
{
writer.WriteStartObject();
writer.WritePropertyName("id");
writer.WriteValue(p.Id.ToString("N"));
writer.WritePropertyName("message");
writer.WriteValue(p.Message);
writer.WritePropertyName("title");
writer.WriteValue(p.Title);
writer.WritePropertyName("type");
writer.WriteValue(p.Type.ToString().ToLower());
writer.WriteEndObject();
}
writer.WriteEndArray();
}
}
示例13: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var list = (HalResource)value;
list.Links.Add(new Link
{
Rel = "self",
Href = list.Href
});
writer.WriteStartObject();
writer.WritePropertyName("_links");
serializer.Serialize(writer, list.Links);
writer.WritePropertyName("_embedded");
writer.WriteStartObject();
writer.WritePropertyName(list.Rel);
writer.WriteStartArray();
foreach (HalResource halResource in (IEnumerable)value)
{
serializer.Serialize(writer, halResource);
}
writer.WriteEndArray();
writer.WriteEndObject();
writer.WriteEndObject();
}
示例14: WriteJsonCoordinatesEnumerable
protected void WriteJsonCoordinatesEnumerable(JsonWriter writer, IEnumerable<Coordinate[]> coordinates, JsonSerializer serializer)
{
writer.WriteStartArray();
foreach (Coordinate[] coordinate in coordinates)
WriteJsonCoordinates(writer, coordinate, serializer);
writer.WriteEndArray();
}
示例15: writeErrors
private void writeErrors(ExecutionErrors errors, JsonWriter writer, JsonSerializer serializer)
{
if (errors == null || errors.Count == 0)
{
return;
}
writer.WritePropertyName("errors");
writer.WriteStartArray();
errors.Apply(error =>
{
writer.WriteStartObject();
writer.WritePropertyName("message");
serializer.Serialize(writer, error.Message);
if (error.Locations != null)
{
writer.WritePropertyName("locations");
serializer.Serialize(writer, error.Locations);
}
writer.WriteEndObject();
});
writer.WriteEndArray();
}