This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit f927d0e66a697170fa599dd82f1423c1bb4c3461
tree d8b0bbebe1ac2a7d46ff864081e9a3b984d12c71
parent f5c73dec02851987a756e3b772d8756c0466521c
tree d8b0bbebe1ac2a7d46ff864081e9a3b984d12c71
parent f5c73dec02851987a756e3b772d8756c0466521c
| name | age | message | |
|---|---|---|---|
| |
LICENSE | ||
| |
README.textile | ||
| |
lib/ | ||
| |
spec/ |
README.textile
JsonPrinter allows you to convert arbitrarily nested Ruby data structures into
human-and-machine-readable JSON output. The input data can be any combination
of arrays, hashes, symbols, strings, numbers, times, and false, true, and nil values.
data =
{"attribute" => "value",
"blank" => nil,
"list" =>
[true,
2,
"elem_number_three"],
"nested_hash" =>
{"key" => 7,
"other_key" => 13.5}}
JsonPrinter.render(data)
#=>
{"nested_hash":
{"other_key": 13.5,
"key": 7},
"list":
[true,
2,
"elem_number_three"],
"blank": null,
"attribute": "value"}
JSON.parse(JsonPrinter.render(data)) == data
#=> true
The printer recognizes instances of ActiveSupport::OrderedHash or other Hash-like objects responding to #keys and will render their attributes in order:
data =
ActiveSupport::OrderedHash.new(
[["foo", "bar"], ["biz", "bat"], ["cat", "hat"]])
JsonPrinter.render(data)
#=>
{"foo": "bar",
"biz": "bat",
"cat", "hat"}
Copyright 2009 Mark McGranaghan and released under an MIT license.








