移出Json物件的三級屬性

猫狼發表於2024-07-27
        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");
            }
        }

兩個物件移出不同的屬性

相關文章