Avro.JsonHelper.GetRequiredInteger C# (CSharp) Method

GetRequiredInteger() public static method

public static GetRequiredInteger ( JToken j, string field ) : int
j JToken
field string
return int
        public static int GetRequiredInteger(JToken j, string field)
        {
            ensureValidFieldName(field);
            JToken child = j[field];
            if (null == child) throw new SchemaParseException(string.Format("No \"{0}\" JSON field: {1}", field, j));

            if (child.Type == JTokenType.Integer) return (int) child;
            throw new SchemaParseException("Field " + field + " is not an integer");
        }

Usage Example

Example #1
0
        /// <summary>
        /// Static function to return new instance of the fixed schema class
        /// </summary>
        /// <param name="jtok">JSON object for the fixed schema</param>
        /// <param name="names">list of named schema already parsed in</param>
        /// <param name="encspace">enclosing namespace of the fixed schema</param>
        /// <returns></returns>
        internal static FixedSchema NewInstance(JToken jtok, PropertyMap props, SchemaNames names, string encspace)
        {
            SchemaName name    = NamedSchema.GetName(jtok, encspace);
            var        aliases = NamedSchema.GetAliases(jtok, name.Space, name.EncSpace);

            return(new FixedSchema(name, aliases, JsonHelper.GetRequiredInteger(jtok, "size"), props, names));
        }
All Usage Examples Of Avro.JsonHelper::GetRequiredInteger