Avro.JsonHelper.writeIfNotNullOrEmpty C# (CSharp) Method

writeIfNotNullOrEmpty() static private method

static private writeIfNotNullOrEmpty ( Newtonsoft writer, string key, string value ) : void
writer Newtonsoft
key string
value string
return void
        internal static void writeIfNotNullOrEmpty(Newtonsoft.Json.JsonTextWriter writer, string key, string value)
        {
            if (string.IsNullOrEmpty(value)) return;
            writer.WritePropertyName(key);
            writer.WriteValue(value);
        }
    }

Usage Example

Example #1
0
        /// <summary>
        /// Writes the Field class in JSON format
        /// </summary>
        /// <param name="writer">JSON writer</param>
        /// <param name="names">list of named schemas already written</param>
        /// <param name="encspace">enclosing namespace for the field</param>
        protected internal void writeJson(JsonTextWriter writer, SchemaNames names, string encspace)
        {
            writer.WriteStartObject();
            JsonHelper.writeIfNotNullOrEmpty(writer, "name", this.Name);
            JsonHelper.writeIfNotNullOrEmpty(writer, "doc", this.Documentation);

            if (null != this.DefaultValue)
            {
                writer.WritePropertyName("default");
                this.DefaultValue.WriteTo(writer, null);
            }
            if (null != this.Schema)
            {
                writer.WritePropertyName("type");
                Schema.WriteJson(writer, names, encspace);
            }

            if (null != this.Props)
            {
                this.Props.WriteJson(writer);
            }

            if (null != aliases)
            {
                writer.WritePropertyName("aliases");
                writer.WriteStartArray();
                foreach (string name in aliases)
                {
                    writer.WriteValue(name);
                }
                writer.WriteEndArray();
            }

            writer.WriteEndObject();
        }
All Usage Examples Of Avro.JsonHelper::writeIfNotNullOrEmpty