How Big Is This JSON?

I found that I continually overestimated the size of JSON payloads, so I figured I might as well do something about it!

I created https://howbigisthisjson.netlify.app mostly to help myself, but following a familiar template of making a very simple micromaterial that can be shared publicly.

easy mode, pick one of the options

In Easy Mode, you just see three options, all about 20% different in length. This is a simple select-type item where you have a bit of scaffolding towards what the correct answer is, but it’s not that authentic, because you wouldn’t normally have something like this available.

…okay, you probably have a simple command-line utility to tell you length, like:

$ cat payload.json | sed 's/[[:space:]]//g' | wc -c

…but we’re training our guessing muscles here for the times when you’re not very close to those tools.

The correct answer is one of those, and the other two are about 20% of the length different. I didn’t get too smart with this one, just calculated 20% of the actual answer and generated the others to be multiples of that distance away.

So the situations are basically:

  • correct answer
  • correct answer + 20%
  • correct answer + 20%

  • correct answer – 20%
  • correct answer
  • correct answer + 20%

  • correct answer – 40%
  • correct answer – 20%
  • correct answer

This is a bit clunky, but I was trying to find the simplest way to generate distractors that were reasonable (so smaller shown payloads have choices that are much closer together).

in hard mode, you enter your guess

In Hard Mode, you are shown the json payload and have to enter your guess. This corresponds to a supply-type item, and is much more difficult. It’s also much more authentic.

I couldn’t settle on a simple and straightforward way to express how close your guess was, so I went with a very basic calculation of:

absolute value(your guess – actual length) / actual length

I suppose something like a rendered dart board might be a better visual, but I didn’t feel like putting too much time into it (PRs open!).

To return to a theme of micromaterials, the strength of this exercise is that it’s extremely simple and focused, giving you as much or as little practice as you like. It’s available all the time, and randomly generates the material for you.

I guess one potential improvement would be to use actual real json payloads, but that would be much more complex for not that much benefit.

Source code: https://github.com/lpmi-13/howbigisthisjson

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s