pedantic formatting edit
splitting the library function from the example code so it can be used as a basic library
use the PHP 5.4 native method when it is available
gitignore editor backup files, etc. + gitattributes to make sure the files always check in with a known, fixed format irrespective of the current development platform
optimization: last round would be nil as it would be 'processing' past the end of the input, i.e. an empty char.
fixing the example to work with Apache web server and proper UTF-8 processing so the example Unicode (Japanese) is not corrupted irrevocably by PHP
fix: only use the PHP 5.4 default pretty printing JSON conversion when the input is NOT a JSON string yet! (otherwise you get very much unwanted results ;-) )
fix the indenting/whitespace handling in the code and always put a space after a colon after a field name
one indent level is one TAB instead of 2 spaces to match PHP 5.4 json_encode($$$, JSON_PRETTY_PRINT) as close as possible.
fix grave error which eats all whitespace INSIDE json string values!
Merge pull request #1 from GerHobbelt/master

some fixes to the formatter and it now also can process raw input into json