本文整理汇总了C#中Newtonsoft.Json.JsonWriter.WritePropertyName方法的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter.WritePropertyName方法的具体用法?C# JsonWriter.WritePropertyName怎么用?C# JsonWriter.WritePropertyName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.WritePropertyName方法的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: Write
public void Write(JsonWriter writer)
{
Validate();
writer.WriteStartObject();
writer.WritePropertyName("key");
writer.WriteValue(Key);
if (!string.IsNullOrEmpty(ChangeMessage))
{
writer.WritePropertyName("changeMessage");
writer.WriteValue(ChangeMessage);
}
if (!string.IsNullOrEmpty(Label))
{
writer.WritePropertyName("label");
writer.WriteValue(Label);
}
if (TextAlignment != FieldTextAlignment.Unspecified)
{
writer.WritePropertyName("textAlignment");
writer.WriteValue(TextAlignment);
}
WriteKeys(writer);
writer.WritePropertyName("value");
WriteValue(writer);
writer.WriteEndObject();
}
示例3: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var heartActivitiesIntraday = value as HeartActivitiesIntraday;
//{
writer.WriteStartObject();
// "DatasetInterval" : "1"
writer.WritePropertyName("DatasetInterval");
writer.WriteValue(heartActivitiesIntraday.DatasetInterval);
// "DatasetType" : "SecondsHeartrate"
writer.WritePropertyName("DatasetType");
writer.WriteValue(heartActivitiesIntraday.DatasetType);
writer.WritePropertyName("Dataset");
writer.WriteStartArray();
foreach (var datasetInverval in heartActivitiesIntraday.Dataset)
{
// "Time" : "2008-09-22T14:01:54.9571247Z"
writer.WritePropertyName("Time");
writer.WriteValue(datasetInverval.Time.ToString("o"));
// "Value": 1
writer.WritePropertyName("Value");
writer.WriteValue(datasetInverval.Value);
}
writer.WriteEndArray();
//}
writer.WriteEndObject();
}
示例4: 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();
}
示例5: 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();
}
}
示例6: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var t = value as ITermsQuery;
if (t == null) return;
var settings = serializer.GetConnectionSettings();
var field = settings.Inferrer.Field(t.Field);
writer.WriteStartObject();
{
if (t.Terms.HasAny())
{
writer.WritePropertyName(field);
serializer.Serialize(writer, t.Terms);
}
else if (t.TermsLookup != null)
{
writer.WritePropertyName(field);
serializer.Serialize(writer, t.TermsLookup);
}
if (t.Boost.HasValue)
{
writer.WritePropertyName("boost");
writer.WriteValue(t.Boost.Value);
}
if (!t.Name.IsNullOrEmpty())
{
writer.WritePropertyName("_name");
writer.WriteValue(t.Name);
}
}
writer.WriteEndObject();
}
示例7: Write
public void Write(JsonWriter writer)
{
Validate();
writer.WriteStartObject();
writer.WritePropertyName("proximityUUID");
writer.WriteValue(ProximityUUID);
if (!string.IsNullOrEmpty(RelevantText))
{
writer.WritePropertyName("relevantText");
writer.WriteValue(RelevantText);
}
if (Minor.HasValue)
{
writer.WritePropertyName("minor");
writer.WriteValue(Minor);
}
if (Major.HasValue)
{
writer.WritePropertyName("major");
writer.WriteValue(Major);
}
writer.WriteEndObject();
}
示例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 model = value as LinkModel;
if(model!=null)
{
writer.WriteStartObject();
writer.WritePropertyName("href");
writer.WriteValue(model.Href);
writer.WritePropertyName("rel");
writer.WriteValue(model.Rel);
if(!model.Method.Equals("GET",StringComparison.OrdinalIgnoreCase))
{
writer.WritePropertyName("method");
writer.WriteValue(model.Method);
}
if(model.IsTemplated)
{
writer.WritePropertyName("isTemplated");
writer.WriteValue(model.IsTemplated);
}
writer.WriteEndObject();
}
}
示例10: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
MatchAllQuery term = (MatchAllQuery)value;
if (term != null)
{
writer.WriteStartObject();
writer.WritePropertyName("match_all");
writer.WriteStartObject();
if (!string.IsNullOrEmpty(term.NormsField))
{
writer.WritePropertyName("norms_field");
writer.WriteValue(term.NormsField);
}
if (term.Boost > 0)
{
writer.WritePropertyName("boost");
writer.WriteValue(term.Boost);
}
writer.WriteEndObject();
writer.WriteEndObject();
}
}
示例11: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
FieldQuery term = (FieldQuery)value;
if (term != null)
{
writer.WriteStartObject();
writer.WritePropertyName("field");
writer.WriteStartObject();
writer.WritePropertyName(term.Field);
writer.WriteValue(term.QueryString);
if(!term.Boost.Equals(default(float)))
{
writer.WritePropertyName("boost");
writer.WriteValue(term.Boost);
}
if (term.EnablePositionIncrements != default(bool))
{
writer.WritePropertyName("enable_position_increments");
writer.WriteValue(term.EnablePositionIncrements.ToString().ToLower());
}
writer.WriteEndObject();
writer.WriteEndObject();
}
}
示例12: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
FeatureResult f = (FeatureResult)value;
writer.WriteStartObject();
if (f.Id != null){
writer.WritePropertyName("id");
writer.WriteValue(f.Id);
}
if (f.Properties != null) {
writer.WritePropertyName("properties");
serializer.Serialize(writer, f.Properties);
}
writer.WritePropertyName("type");
serializer.Serialize(writer, (f.Type));
if (f.Geometry != null) {
writer.WritePropertyName("geometry");
serializer.Serialize(writer, f.Geometry);
}
writer.WriteEndObject();
}
示例13: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
// value should be an entity or a collection of entities.
var singleEntity = !(value is IEnumerable);
writer.WriteStartObject();
writer.WritePropertyName("@odata.context");
writer.WriteValue(GenerateContextUrlString(value, singleEntity));
if (!singleEntity)
{
writer.WritePropertyName("value");
writer.WriteStartArray();
}
if (singleEntity)
{
WriteEntity(writer, value);
}
else
{
foreach (var o in (IEnumerable)value)
{
writer.WriteStartObject();
WriteEntity(writer, o);
writer.WriteEndObject();
}
}
if (!singleEntity)
{
writer.WriteEndArray();
}
writer.WriteEndObject();
}
示例14: WriteJson
public override void WriteJson(JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)
{
if(value == null)
{
writer.WriteNull();
return;
}
MerkleNode mn = value as MerkleNode;
writer.WriteStartObject();
writer.WritePropertyName("Data");
serializer.Serialize(writer, mn.Data);
writer.WritePropertyName("Hash");
serializer.Serialize(writer, mn.Hash);
writer.WritePropertyName("Links");
serializer.Serialize(writer, mn.Links);
writer.WritePropertyName("Name");
serializer.Serialize(writer, mn.Name);
writer.WritePropertyName("Size");
serializer.Serialize(writer, mn.Size);
writer.WriteEndObject();
}
示例15: WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var links = (IList<Link>) value;
writer.WriteStartObject();
foreach (var link in links)
{
writer.WritePropertyName(link.Rel);
writer.WriteStartObject();
writer.WritePropertyName("href");
writer.WriteValue(link.Href);
if (link.IsTemplated)
{
writer.WritePropertyName("isTemplated");
writer.WriteValue(true);
}
if (!string.IsNullOrWhiteSpace(link.Title))
{
writer.WritePropertyName("title");
writer.WriteValue(link.Title);
}
writer.WriteEndObject();
}
writer.WriteEndObject();
}