

Ask YC: JSON Editor - ra

Hello,
Anyone know of a decent JSON editor for OS X / Linux, that doesn't require Eclipse?<p>Preferably FOSS.<p>many thanks
======
bootload
_"... Anyone know of a decent JSON editor for OS X / Linux ..."_

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>

------
toxik
Alternatively, you could use your "native" language and encode the data. I do
that a lot, like so (Python):

    
    
      >>> 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]

~~~
SwellJoe
In the real world, I would think all JSON would be produced by code (there are
easier to read/write formats for human generated data, like YAML or key=value
or INI style config files, for which there are numerous parsers in every
language I can think of).

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.

------
kobs
If you really want an "editor", you could check out the graphical JSON editor
included with the ruby json package:
<http://json.rubyforge.org/screenshots.html>

~~~
ra
Great! Thanks very much - just what I was looking for.

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

------
jrockway
I like YAML for actual editing, JSON is more of a "machine language" than
something that's human-readable.

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.

