Ask YC: JSON Editor
Hello,
Anyone know of a decent JSON editor for OS X / Linux, that doesn't require Eclipse?
Preferably FOSS.
many thanks
Preferably FOSS.
many thanks
Vim, emacs or some other text editor.
One of the key ideas behind JSON is to make it editable by humans and readable by machines. So a text editor and check the output with http://www.jsonlint.com/ or use your favourite language to parse it ~ http://www.json.org
>>> import simplejson
>>> v = ["My Values", {"type": 123, "Megahertz": 123.456}]
>>> print simplejson.dumps(v)
["My Values", {"Megahertz": 123.456, "type": 123}]
Heck, you could even do this: >>> while True: print simplejson.dumps(input("JSON> "))
...
JSON> ["Hello", "World", [123, 321]]
["Hello", "World", [123, 321]]
JSON> [True, False, None]
[true, false, null]Perl has JSON::XS (my favorite) and the compatible pure-Perl JSON::PP, as well a few other options of varying degrees of quality and performance.
use JSON::XS;
my $json_reply = JSON::XS->new;
print $json_reply->encode(["Hello", "World", [123, 321]]);
We use map and grep extensively to produce the JSON to build our GUI elements, and it works like magic. I'm sure Ruby and PHP have similar libraries.I only want an editor to fiddle with (tidy up) some data, which is in JSON format becasue it was exported from the django dumpdata command.
As it's a one off task - I didn't really want to get into writing a script.
Cheers
To convert YAML to JSON, something like:
perl -MYAML=Load -MJSON::Any -E 'say JSON::Any->new->Dump(Load(do { local $/; <> }))'
should do the trick.