大 JSON 文件 - 如何在服务器中压缩并在客户端解压缩

Big JSON file - how to compress in the server and decompress in the client side?

本文关键字:压缩 客户端 解压缩 服务器 文件 JSON      更新时间:2023-09-26

我有一个大小约为 2-3 MB 的 json 文件。当我们发送到客户端时,我想在服务器端压缩这个 json,并在客户端解压缩。

我的客户端建立在AngularJS SPA上,并从Web API获取json输出。

{
  "firstName": "John",
  "lastName": "Smith",
  "age": 25,
  "address":
  {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10021"
  },
  "phoneNumber":
  [
    {
      "type": "home",
      "number": "212 555-1234"
    },
    {
      "type": "fax",
      "number": "646 555-4567"
    }
  ]
}

您可以尝试使用 IIS 中的压缩功能。

另外,考虑使用分页来获取部分数据。