public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (reader.TokenType != JsonToken.StartArray)
            {
                return(null);
            }

            var fields = new Fields();

            while (reader.TokenType != JsonToken.EndArray)
            {
                // as per https://github.com/elastic/elasticsearch/pull/29639 this can now be an array of objects
                reader.Read();
                switch (reader.TokenType)
                {
                case JsonToken.String:
                    fields.And((string)reader.Value);
                    break;

                case JsonToken.StartObject:
                    /// TODO 6.4 this is temporary until we add proper support for doc_values format
                    reader.Read();                             // "field";
                    var field = reader.ReadAsString();
                    fields.And(field);
                    while (reader.TokenType != JsonToken.EndObject)
                    {
                        reader.Read();
                    }
                    reader.Read();                             // "}";
                    break;
                }
            }
            return(fields);
        }
Beispiel #2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (reader.TokenType != JsonToken.StartArray)
            {
                return(null);
            }
            var fields = new Fields();

            while (reader.TokenType != JsonToken.EndArray)
            {
                var field = reader.ReadAsString();
                if (reader.TokenType == JsonToken.String)
                {
                    fields.And(field);
                }
            }
            return(fields);
        }