using System.Collections.Generic;
using Newtonsoft.Json.Converters;
public static void Main()
var json = "{\"childrenOp\": \"and\", \"children\": [{\"value\": \"text\",\"importance\": 100},{\"childrenOp\": \"or\",\"children\": [{\"value\": \"text2\",\"importance\": 100},{\"value\": \"text3\",\"importance\": 100},{\"childrenOp\": \"and\",\"children\": [{\"value\": \"text4\",\"importance\": 100}]}]}]}";
var model = JsonConvert.DeserializeObject<ElementModel>(json);
Console.WriteLine(JsonConvert.SerializeObject(model, Formatting.Indented));
public class ElementModel
[JsonConverter(typeof(StringEnumConverter))]
public Operator? ChildrenOp { get; set; }
public List<ElementModel> Children { get; set; }
public string Value { get; set; }
public int? Importance { get; set; }
public ElementModel(string value, int importance)
public ElementModel(Operator childrenOp, params ElementModel[] children)
Children = children.ToList();