PackUtils/JsonUtility.cs
/// <summary>
/// Remove empty childrens from jtoken (when object)
/// </summary>
/// <param name="jtoken"></param>
/// <returns></returns>
Remove empty childrens from jtoken (when object)
Remove empty childrens from jtoken ( when object )
private static JToken RemoveEmptyChildrenFromObject(this JToken jtoken)
        {
            var copy = new JObject();
            foreach (JProperty prop in jtoken.Children<JProperty>())
            {
                var child = prop.Value;
                if (child.HasValues)
                {
                    child = child.RemoveEmptyChildren();
                }
                if (!child.IsEmpty())
                {
                    copy.Add(prop.Name, child);
                }
            }
            return copy;
        }
private static JToken RemoveEmptyChildrenFromObject ( this JToken jtoken ) { var copy = new JObject ( ) ; foreach ( JProperty prop in jtoken . Children < JProperty > ( ) ) { var child = prop . Value ; if ( child . HasValues ) { child = child . RemoveEmptyChildren ( ) ; } if ( ! child . IsEmpty ( ) ) { copy . Add ( prop . Name , child ) ; } } return copy ; }
Remove empty childrens from jtoken (when object)
Remove empty childrens from jtoken ( when object )
None
JToken
this
jtoken
None