Is it worth the effort to try to reduce JSON size?

后端 未结 5 1974
遥遥无期
遥遥无期 2020-12-24 02:21

I am submitting relatively lots of data from a mobile application (up to 1000 JSON objects), that I would normally encode like this:

[{
    id: 12,
    score         


        
5条回答
  •  南笙
    南笙 (楼主)
    2020-12-24 02:53

    Although is an old question, I'd like to put some words.

    In my experience, large differences in json raw size, amount very little after compression. I prefer to keep it human readable.

    In real case numbers: a json file of 1,29MB, and the optimized version of 145KB, when compressed, where of 32KB and 9KB.

    Except in extreme conditions, I think this kind of differences are negligibles and the cost in readability is huge.

    A:

    {
      "Code": "FCEB97B6",
      "Date": "\/Date(1437706800000)\/",
      "TotalQuantity": 1,
      "Items": [
        {
          "CapsulesQuantity": 0,
          "Quantity": 1,
          "CurrentItem": {
            "ItemId": "SHIELD_AXA",
            "Order": 30,
            "GroupId": "G_MODS",
            "TypeId": "T_SHIELDS",
            "Level": 0,
            "Rarity": "R4",
            "UniqueId": null,
            "Name": "AXA Shield"
          }
        }
      ],
      "FormattedDate": "2015-Jul.-24"
    }
    

    B:

    {
      "fDate": "2016-Mar.-01",
      "totCaps": 9,
      "totIts": 14,
      "rDays": 1,
      "avg": "1,56",
      "cells": {
        "00": {
          "30": 1
        },
        "03": {
          "30": 1
        },
        "08": {
          "25": 1
        },
        "09": {
          "26": 3
        },
        "12": {
          "39": 1
        },
        "14": {
          "33": 1
        },
        "17": {
          "40": 3
        },
        "19": {
          "41": 2
        },
        "20": {
          "41": 1
        }
      }
    }
    

    This are fragments of the two files.

提交回复
热议问题