2010-09-13

JSONView with copy & paste support

Last weekend I picked up Ben Hollis' JSONView extension to tinker it to keep JSON viewed through it copy-and-paste:able, both as a whole and in part. It was rather fun work and within some few hours I had a patch that did the trick, and a few other ones to boot:

jsonp(
{ "This test-case": "shows how JSONView-0.5.copy.paste formats JSON(P)."
, "number": 243
, "object":
{ "It may look a bit weird, at first": "but it's great for development,"
, "array":
[ 1
, 2
, [ 1
, 2
, { "as adding or removing values": "just changes the lines involved,"
}
]
, "and never any surrounding lines with just a comma added or removed."
, "This makes diffs look way prettier and cleaner in github changesets."
]
, "more\u0000challenging": "stuff \t with \b misc \f control ☠ codes\r\n"
}
, "bool1": true
, "bool2": false
, "null": null
, "japanese": "明日がある。"
, "url": "http://jsonview.com"
, "notnurl": "http://jsonview.com is great"
, "zero": 0
, "float": 47.11
, "empty": ""
})


I sent Ben a patch, but not having heard anything back, I figured I might as well share the results here too, as it's all MIT licensed goodness (as is my patched version, of course). You can either download an installable xpi build, or fork my repository from github.

My edits are all on a branch named after my github user -- a practice I can recommend, when mirroring some svn upstream repository (with git-svn, for instance); it simplifies the process of tracking vendor updates to a mere git svn rebase on master (for you -- git-svn, sadly, is not able to push its metadata about the non-git upstream to github) and lets other people reuse your pristine vendor branch for their own purposes.

Enjoy your easier-to-handle JSON! I guess next step would be to integrate these improvements into the Chrome fork Jamie Wilkinson is maintaining. Any takers?