So, I just uploaded two files: "PrettyJSONEncoder.as" and "JSON.as".
Basically, it's a modification of the JSON encoder that pretty-prints
its output. "PrettyJSONEncoder.as" had changes to method signatures
and code in enough places to justify a replacement file, rather than
an subclass. (They're trivial changes, but widespread.) "JSON.as" is
actually a subclass of "
com.adobe.serializer.json.JSON.as", and barely
tweaks it. I chose the same class name so that it could be a near
drop-in replacement for the standard encoder, when desired. (Change
the "import" line in your code, add a line in the init somewhere to
set the default encoding to be pretty-printing, and leave the rest of
your code as-is.)
This also has support for setting the "linebreak" and "indent" strings
used, which means if you set those strings to be empty (""), then it
functions identically to the standard JSON encoder.
If there is interest, I could put together a version that is actually
a patch against the existing code, so that it could get added into the
main codebase. (I'd like that, as otherwise I'll have to continually
apply changes made in the standard JSONEncoder into this one. That
seems very tedious. And others on the web have asked for this
functionality.)
Nonetheless, these are currently tossed in a separate package, so they
won't interfere with the existing code. I probably picked a bad
choice for a package name ("com.adobe.serializer.json.prettyjson"),
since I don't actually work for Adobe. But you get the idea.
Have fun,
Bibek