using System.Collections.Generic;
const string jsonString = "{\"LogFieldsMapping\": {\"IDField\": { \"FieldName\": \"_id\" },\"LevelField\": {\"FieldName\": \"_source.level\",\"FieldValue\": [{ \"value\": \"Information\" },{ \"value\": \"Error\" }]}}}";
public static void Main()
Root queryObject = new();
Root2 json = JsonConvert.DeserializeObject<Root2>(jsonString);
foreach(FieldValue fieldValue in json.LogFieldsMapping.LevelField.FieldValue) {
queryObject.query.@bool.should.Add(
Console.WriteLine(JsonConvert.SerializeObject(queryObject));
public string level { get; set; }
public Match match { get; set; }
public DateTime gte { get; set; }
public DateTime lt { get; set; }
[JsonProperty("@timestamp")]
public Timestamp Timestamp { get; set; }
public Range range { get; set; }
public List<Should> should { get; set; }
public List<Filter> filter { get; set; }
public int minimum_should_match { get; set; }
public Bool @bool { get; set; }
query.@bool.should = new();
public int size { get; set; }
public Query query { get; set; }
public string FieldName { get; set; }
public string value { get; set; }
public string FieldName { get; set; }
public List<FieldValue> FieldValue { get; set; }
public class LogFieldsMapping
public IDField IDField { get; set; }
public LevelField LevelField { get; set; }
public LogFieldsMapping LogFieldsMapping { get; set; }