Fix handling of jsonEncode prettyPrint flag

I noticed that in PHP 5.4+, the jsonEncode method does not respect the prettyPrint flag.  This commit updates the logic to respect that flag.  I also added tests to prove it works and prevent future regressions.