namespace BehaviorTreeSlayer
{

    public class Entry : Sequence
    {
        public string Serielize(TreeNode node)
        {
            string s = UnityEngine.JsonUtility.ToJson(node);
            if (node is ComponentNode)
            {
                ComponentNode cp = node as ComponentNode;
                int count = cp.childs.Count;
                if (count > 0)
                {
                    string c = "\"childs\":[";
                    for (int i = 0; i < count; i++)
                    {
                        c += Serielize(cp.childs[i]);
                        if (i < count - 1)
                        {
                            c += ",";
                        }
                    }
                    c += "],";
                    int idx = s.IndexOf("Sid");
                    s = s.Insert(idx - 1, c);

                }
            }
            return s;
        }
    }

}