1. var commandData = new JObject();
    2. foreach (System.Reflection.PropertyInfo p in data.GetType().GetProperties())
    3. {
    4. if (p.GetValue(data) != null)
    5. {
    6. commandData.Add(new JProperty(p.Name, p.GetValue(data)));
    7. }
    8. }