public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { Audience audience = value as Audience; if (audience == null) { return; } audience.Check(); if (audience.isAll()) { writer.WriteValue(audience.allAudience); } else { string str = JsonConvert.SerializeObject((object)audience.dictionary); writer.WriteRawValue(str); } }