移出Json对象的三级属性

        JObject jo = JObject.FromObject(pd);
        if (jo.SelectToken("elements") is JArray ja)
        {
            //((JObject)(jae[0])).Remove("type");
            JObject jac = (JObject)(ja[0]);
            if (jac.SelectToken("json") is JObject jc)
            {
                List<string> ps = new List<string>() { "fontFamily", "fontSize", "textAlignHorizonral", "textAlignVertical", "letterSpacing", "lineSpacing", "lineMode", "fontStyle" };
                foreach (string p in ps)
                {
                    jc.Remove(p);
                }
            }
            JObject jat = (JObject)(ja[1]);
            if (jac.SelectToken("json") is JObject jt)
            {
                jt.Remove("codeType");
            }
        }

两个对象移出不同的属性

posted @ 2024-07-27 08:22  猫狼  阅读(7)  评论(0编辑  收藏  举报