本文整理汇总了C#中Newtonsoft.Json.JsonWriter.WriteEndObject方法的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter.WriteEndObject方法的具体用法?C# JsonWriter.WriteEndObject怎么用?C# JsonWriter.WriteEndObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.WriteEndObject方法的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 f = value as IGeoBoundingBoxFilter;
if (f == null || (f.IsConditionless && !f.IsVerbatim)) return;
var contract = serializer.ContractResolver as SettingsContractResolver;
if (contract == null)
return;
var field = contract.Infer.PropertyPath(f.Field);
if (field.IsNullOrEmpty())
return;
writer.WriteStartObject();
{
writer.WritePropertyName(field);
writer.WriteStartObject();
{
WriteProperty(writer, f, "top_left", f.TopLeft);
WriteProperty(writer, f, "bottom_right", f.BottomRight);
}
writer.WriteEndObject();
SerializeProperty(writer, serializer, f, "type", f.GeoExecution);
WriteProperty(writer, f, "_cache", f.Cache);
WriteProperty(writer, f, "_cache_key", f.CacheKey);
WriteProperty(writer, f, "_name", f.FilterName);
}
writer.WriteEndObject();
}
示例3: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
TopChildrenQuery term = (TopChildrenQuery)value;
if (term != null)
{
writer.WriteStartObject();
writer.WritePropertyName("top_children");
writer.WriteStartObject();
writer.WritePropertyName("type");
writer.WriteValue(term.Type);
writer.WritePropertyName("score");
writer.WriteValue( term.Score);
writer.WritePropertyName("factor");
writer.WriteValue(term.Factor);
writer.WritePropertyName("incremental_factor");
writer.WriteValue(term.IncrementalFactor);
writer.WritePropertyName("query");
serializer.Serialize(writer, term.Query);
writer.WriteEndObject();
writer.WriteEndObject();
}
}
示例4: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
ElasticQuery term = (ElasticQuery)value;
if (term != null)
{
writer.WriteStartObject();
writer.WriteRaw("\"from\": " + term.From);
writer.WriteRaw(",\"size\": " + term.Size + ",");
writer.WritePropertyName("query");
serializer.Serialize(writer, term.Query);
if (term.Fields != null && term.Fields.Count > 0)
{
writer.WritePropertyName("fields");
writer.WriteStartArray();
foreach (var field in term.Fields)
{
writer.WriteRawValue("\"" + field + "\"");
}
writer.WriteEndArray();
}
if (term.SortItems != null && term.SortItems.Count > 0)
{
writer.WritePropertyName("sort");
writer.WriteStartObject();
foreach (var sortItem in term.SortItems)
{
if (sortItem != null)
{
writer.WritePropertyName(sortItem.FieldName);
writer.WriteValue(sortItem.SortType.ToString().ToLower());
}
}
writer.WriteEndObject();
}
//facets
if (term.Facets != null)
{
writer.WritePropertyName("facets");
serializer.Serialize(writer, term.Facets);
}
//hightlight
if(term.Hightlight!=null)
{
writer.WritePropertyName("highlight");
serializer.Serialize(writer,term.Hightlight);
}
if (term.Explain)
{
writer.WriteRaw(",\"explain\": " + term.Explain.ToString().ToLower());
}
writer.WriteEndObject();
}
}
示例5: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var request = value as UpdateListItemsRequest;
if (request == null)
{
writer.WriteNull();
return;
}
/*
"additems" : ["3","4","5"],
"adduniqueitems" : ["1","6"],
"removeitems": ["2","5"]
*/
writer.WriteStartObject();
writer.WritePropertyName(request.Property );
writer.WriteStartObject();
if (request.ItemsToAdd.Count > 0)
{
if (request.AddUniquely == true)
writer.WriteArray("adduniqueitems", request.ItemsToAdd);
else
writer.WriteArray("additems", request.ItemsToAdd);
}
if (request.ItemsToRemove.Count > 0)
writer.WriteArray("removeitems", request.ItemsToRemove);
writer.WriteEndObject();
writer.WriteEndObject();
}
示例6: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
DisjunctionMaxQuery term = (DisjunctionMaxQuery)value;
if (term != null)
{
if (term.Queries == null || term.Queries.Count < 0)
{
throw new ArgumentException();
}
writer.WriteStartObject();
writer.WritePropertyName("dis_max");
writer.WriteStartObject();
writer.WritePropertyName("tie_breaker");
writer.WriteValue(term.TieBreaker);
writer.WritePropertyName("boost");
writer.WriteValue(term.Boost);
writer.WritePropertyName("queries");
writer.WriteStartArray();
foreach (var query in term.Queries)
{
serializer.Serialize(writer, query);
}
writer.WriteEndArray();
writer.WriteEndObject();
writer.WriteEndObject();
}
}
示例7: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
TermQuery term = (TermQuery)value;
if (term != null)
{
/* Writes the following json
* {
* "term":
* {
* "term.Field":
* {
* "term": "term.Value",
* "boost": term.Boost
* }
* }
* }
*/
writer.WriteStartObject();
writer.WritePropertyName("term");
writer.WriteStartObject();
writer.WritePropertyName(term.Field);
writer.WriteStartObject();
writer.WritePropertyName("term");
writer.WriteValue(term.Value);
writer.WritePropertyName("boost");
writer.WriteValue(term.Boost);
writer.WriteEndObject();
writer.WriteEndObject();
writer.WriteEndObject();
}
//writer.WriteRawValue(string.Format("{{term: {{ \"{0}\" : {{ \"term\" : \"{1}\", \"boost\":{2} }}}} }}", term.Field, term.Value, term.Boost));
}
示例8: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (writer == null)
throw new ArgumentNullException("writer");
if (value == null)
throw new ArgumentNullException("value");
if (serializer == null)
throw new ArgumentNullException("serializer");
if (!(value is IFeature))
{
string s = String.Format("IFeature expected but was {0}", value.GetType().Name);
throw new ArgumentException(s);
}
writer.WriteStartObject();
writer.WritePropertyName("type");
writer.WriteValue("Topology");
writer.WritePropertyName("objects");
writer.WriteStartObject();
writer.WritePropertyName("data");
IEnumerable<Coordinate[]> arcs = WriteFeature(writer, serializer, (IFeature)value);
writer.WriteEndObject();
WriteArcs(writer, serializer, arcs);
writer.WriteEndObject();
}
示例9: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
GeoDistanceFilter term = (GeoDistanceFilter)value;
if (term != null)
{
writer.WriteStartObject();
writer.WritePropertyName("geo_distance");
writer.WriteStartObject();
if (!string.IsNullOrEmpty(term.Distance))
{
writer.WritePropertyName("distance");
writer.WriteValue(term.Distance);
if (!string.IsNullOrEmpty(term.DistanceType))
{
writer.WritePropertyName("distance_type");
writer.WriteValue(term.DistanceType);
}
if (!string.IsNullOrEmpty(term.Field))
{
writer.WritePropertyName(term.Field);
writer.WriteValue(term.Location);
}
}
writer.WriteEndObject();
writer.WriteEndObject();
}
}
示例10: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value.IsNot<NestedFilter>())
{
writer.WriteNull();
return;
}
var filter = (NestedFilter)value;
writer.WriteStartObject();
writer.WritePropertyName("nested");
writer.WriteStartObject();
if (filter.Path.IsNotNull())
{
writer.WritePropertyName("path");
writer.WriteValue(filter.Path);
}
writer.WritePropertyName("filter");
serializer.Serialize(writer, filter.Filter);
if (filter.Join.IsNotNull())
{
writer.WritePropertyName("join");
writer.WriteValue(filter.Join);
}
writer.WriteEndObject();
writer.WriteEndObject();
}
示例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)
{
var facetRequest = (NestedDateHistogramFacetRequest)value;
writer.WriteStartObject();
writer.WritePropertyName("date_histogram");
writer.WriteStartObject();
if (facetRequest.Field.IsNotNullOrEmpty())
{
writer.WritePropertyName("field");
writer.WriteValue(facetRequest.Field);
}
if (facetRequest.Interval.IsNotNull())
{
writer.WritePropertyName("interval");
writer.WriteValue(facetRequest.Interval.ToString().ToLowerInvariant());
}
if (facetRequest.PreTimeZone.IsNotNull())
{
writer.WritePropertyName("pre_zone");
writer.WriteValue(facetRequest.PreTimeZone.BaseUtcOffset.ToString(@"hh\:mm"));
}
writer.WriteEndObject();
if (facetRequest.Nested.IsNotNullOrEmpty())
{
writer.WritePropertyName("nested");
writer.WriteValue(facetRequest.Nested);
}
if (facetRequest.FacetFilter.IsNotNull())
{
writer.WritePropertyName("facet_filter");
serializer.Serialize(writer, facetRequest.FacetFilter);
}
writer.WriteEndObject();
}
示例13: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
PacketEffect effect = (PacketEffect)value;
PacketEffectAttribute effectAttribute = effect.GetType().GetCustomAttribute<PacketEffectAttribute>();
if (effectAttribute == null)
throw new NotSupportedException("All PacketEffect classes must have a PacketEffectAttribute !");
writer.WriteStartObject();
writer.WritePropertyName(effectAttribute.Name);
writer.WriteStartObject();
foreach (PropertyInfo info in value.GetType().GetProperties())
{
string propertyName;
JsonPropertyAttribute propertyAttribute = info.GetCustomAttribute<JsonPropertyAttribute>();
if (propertyAttribute != null)
propertyName = propertyAttribute.PropertyName;
else
propertyName = info.Name;
writer.WritePropertyName(propertyName);
JsonConverterAttribute conversionAttribute = info.GetCustomAttribute<JsonConverterAttribute>();
if (conversionAttribute != null)
writer.WriteRawValue(JsonConvert.SerializeObject(info.GetValue(value), Formatting.None, (JsonConverter)Activator.CreateInstance(conversionAttribute.ConverterType)));
else
writer.WriteRawValue(JsonConvert.SerializeObject(info.GetValue(value)));
}
writer.WriteEndObject();
writer.WriteEndObject();
}
示例14: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
NestedFilter term = (NestedFilter)value;
if (term != null)
{
writer.WriteStartObject();
writer.WritePropertyName("nested");
writer.WriteStartObject();
writer.WritePropertyName("path");
writer.WriteValue(term.Path);
writer.WritePropertyName("query");
if(term.Query!=null)
{
serializer.Serialize(writer, term.Query);
}
else
{
serializer.Serialize(writer, term.Filter);
}
// writer.WritePropertyName("_cache");
// writer.WriteValue(term.Cache);
writer.WriteEndObject();
writer.WriteEndObject();
}
}
示例15: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
TermsFacet term = (TermsFacet)value;
if (term != null)
{
if (term.facetItems != null)
{
writer.WriteStartObject();
foreach (TermsFacet.TermsFacetItem termsFacetItem in term.facetItems)
{
writer.WritePropertyName(termsFacetItem.FacetName);
writer.WriteStartObject();
//1
writer.WritePropertyName("terms");
writer.WriteStartObject();
writer.WritePropertyName("field");
writer.WriteValue(termsFacetItem.Field);
writer.WritePropertyName("size");
writer.WriteValue(termsFacetItem.Size);
writer.WriteEndObject();
//1
writer.WriteEndObject();
}
writer.WriteEndObject();
}
}
}