Homec4science

JSON pretty-printer

Authored by epriestley <git@epriestley.com> on May 23 2011, 17:14.

Description

JSON pretty-printer

Summary:
This is step one of a three-step plan to build "arc add-certificate" which edits
your .arcrc for you since people had a lot of trouble with it at Facebook and I
imagine it causes Bootcamper issues.

I want to be able to print out the final file in a human-readable way, so we
need a JSON pretty printer / formatter. I looked around online for something
since this seems like a thing I shouldn't have to roll, but all I could find was
one in Zend Framework (which I think has some weird license?) which is broken
and silly:

http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Json.php

It does the wrong thing if any string contains "[", "]", "{" or "}", which is
ridiculous. I also found this:

https://gist.github.com/906036

..but who knows what the license on that is, and it's also based on transforming
a serialized JSON string into a pretty string, which is silly and complicated.

Test Plan:
Wrote a test file with some complicated object in it and pretty-encoded it to a
reasonable outcome.

Reviewed By: tuomaspelkonen
Reviewers: tuomaspelkonen, jungejason, aran
CC: aran, epriestley, tuomaspelkonen
Differential Revision: 336

Details

Committed
epriestley <git@epriestley.com>May 26 2011, 03:46
Pushed
aubortMar 17 2017, 12:03
Parents
rPHU5c4349426c65: Merge pull request #6 from lovrop/master
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPHU2bd87dda3798: JSON pretty-printer (authored by epriestley <git@epriestley.com>).May 26 2011, 03:46