nanjo150cm
2019-09-18 11:54 阅读 958

.net core 3.0 System.Text.Json序列化树形结构时内存溢出,该怎么配置

.net core3.0 wei API,默认返回的json序列化改成了System.text.json,
默认的序列化发现在序列树形的数据会出现内存溢出,要怎么配置默认的

Newtonsof序列化后的结果

图片说明

System.Text.Json序列化的结果
图片说明
数据的结果(Newtonsof序列化后)

[
  {
    "ParentID": "",
    "ID": "code",
    "Name": "代码",
    "Contents": [],
    "Children": [
      {
        "ParentID": "code",
        "ID": "database",
        "Name": "database",
        "Contents": [],
        "Children": []
      },
      {
        "ParentID": "code",
        "ID": "dotnet",
        "Name": "dotnet",
        "Contents": [],
        "Children": []
      },
      {
        "ParentID": "code",
        "ID": "javascript",
        "Name": "js",
        "Contents": [],
        "Children": []
      }
    ]
  },
  {
    "ParentID": "",
    "ID": "hardware",
    "Name": "硬件",
    "Contents": [],
    "Children": []
  },
  {
    "ParentID": "",
    "ID": "music",
    "Name": "音乐",
    "Contents": [],
    "Children": []
  },
  {
    "ParentID": "",
    "ID": "photo",
    "Name": "代码",
    "Contents": [],
    "Children": []
  },
  {
    "ParentID": "",
    "ID": "video",
    "Name": "视频",
    "Contents": [],
    "Children": []
  }
]
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

相关推荐