Live data from Hacker News

RJSON: compress JSON to JSON

cliws.com

1–10 of 45 posts

Re: RJSON: compress JSON to JSON

#2
I see a pretty major problem with this. It seems to depend on the order of key value pairs in object literals being defined. The order is not defined by the JSON or the ecmascript standards. So you can't really depend on the order of keys in a json object, unless you explicitly define some order (like alphabetical, for instance). I like the basic concept of compressing json to json but this is not a particularly good way to do it- since the order of those keys may not be preserved in round trips through json encoders and decoders in various languages.

Re: RJSON: compress JSON to JSON

#4

I see a pretty major problem with this. It seems to depend on the order of key value pairs in object literals being defined. The order is not defined by the JSON or the ecmascript standards. So you can't really depend on the order of keys in a json object, unless you explicitly define some order (like alphabetical, for instance). I like the basic concept of compressing json to json but this is not a particularly good…

[deleted]

Re: RJSON: compress JSON to JSON

#5
post #4

I see a pretty major problem with this. It seems to depend on the order of key value pairs in object literals being defined. The order is not defined by the JSON or the ecmascript standards. So you can't really depend on the order of keys in a json object, unless you explicitly define some order (like alphabetical, for instance). I like the basic concept of compressing json to json but this is not a particularly good…

[deleted]

that is only enough to make it seem like it works okay. But as I said, there's nothing in the JSON spec that obligates any intervening party to preserve the order of the keys in the object.

Re: RJSON: compress JSON to JSON

#6

How would it compress and then decompress the following document? {"users": [ {"first": "Homer", "last": "Simpson"}, {"first": "Hank", "last": "Hill"}, [2, "Peter", "Griffin"] }

    {
        "users": [
            {
                "first": "Homer",
                "last": "Simpson"
            },
            [
                2,
                "Hank",
                "Hill"
            ],
            [
                0,
                2,
                "Peter",
                "Griffin"
            ]
        ]
    }
There was a tester linked from the site. Looks like he added the [0, to handle that case.

Re: RJSON: compress JSON to JSON

#7

How would it compress and then decompress the following document? {"users": [ {"first": "Homer", "last": "Simpson"}, {"first": "Hank", "last": "Hill"}, [2, "Peter", "Griffin"] }

There's a demo here: http://www.cliws.com/p/rjson/

It comes it to:

    {
      "users": [
        {
          "first": "Homer",
          "last": "Simpson"
        },
        [
          2,
          "Hank",
          "Hill"
        ],
        [
          0,
          2,
          "Peter",
          "Griffin"
        ]
      ]
    }

Re: RJSON: compress JSON to JSON

#8
> reduce JSON data size and network traffic when gzip isn't available. For example, in-browser 3D-modeling tools like Mydeco 3D-planner may process and send to server megabytes of JSON-data;

`Content-encoding: gzip` anyone?

Re: RJSON: compress JSON to JSON

#9

I see a pretty major problem with this. It seems to depend on the order of key value pairs in object literals being defined. The order is not defined by the JSON or the ecmascript standards. So you can't really depend on the order of keys in a json object, unless you explicitly define some order (like alphabetical, for instance). I like the basic concept of compressing json to json but this is not a particularly good…

I saw the same thing right away. Seems like the first item in the array would have to be used as a hash of key/index pairs to be used for the following items. I guess this would only be useful with large sets of data, the examples makes them look kind of silly =)

So this:

    "users": [
        {"first": "Homer", "last": "Simpson"},
        {"first": "Hank", "last": "Hill"},
        {"first": "Peter", "last": "Griffin"}
    ],
Becomes:

    "users": [
        ["first", "last"],
        ["Homer", "Simpson"],
        ["Hank", "Hill"],
        ["Peter", "Griffin"]
    ],

Re: RJSON: compress JSON to JSON

#10

> reduce JSON data size and network traffic when gzip isn't available. For example, in-browser 3D-modeling tools like Mydeco 3D-planner may process and send to server megabytes of JSON-data; `Content-encoding: gzip` anyone?

I don't believe that browsers let uploads be gzipped, as it can't be sure that the server supports gzipped requests.
Post reply on HN