README.md in json_builder-3.0.2 vs README.md in json_builder-3.0.3
- old
+ new
@@ -1,16 +1,18 @@
-# JSON Builder
+JSON Builder
+============
Rails provides an excellent XML Builder by default to build RSS and ATOM feeds, but nothing to help you build complex and custom JSON data structures. The standard `to_json` works just fine, but can get very verbose when you need full control of what is generated and performance is a factor. JSON Builder hopes to solve that problem.
## Sample Usage
```ruby
require 'json_builder'
json = JSONBuilder::Compiler.generate do
name "Garrett Bjerkhoel"
email "spam@garrettbjerkhoel.com"
+ url root_path
address do
street "1234 1st Ave"
street2 "Apt 1"
city "New York"
state "NY"
@@ -32,10 +34,11 @@
```json
{
"name": "Garrett Bjerkhoel",
"email": "spam@garrettbjerkhoel.com",
+ "url": "/",
"address": {
"street": "1234 1st Ave",
"street2": "Apt 1",
"city": "New York",
"state": "NY",
@@ -106,10 +109,11 @@
num_pages @users.num_pages
results @users do |user|
id user.id
name user.name
body user.body
+ url user_url(url)
links user.links do |link|
url link.url
visits link.visits
last_visited link.last_visited
end
@@ -127,10 +131,11 @@
"results": [
{
"id": 1,
"name": "Garrett Bjerkhoel",
"body": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.",
+ "url": "http://example.com/users/garrett-bjerkhoel",
"links": [
{
"url": "http://github.com/",
"visits": 500,
"last_visited": "2011-11-271T00:00:01Z"
@@ -143,9 +148,10 @@
]
}, {
"id": 2,
"name": "John Doe",
"body": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.",
+ "url": "http://example.com/users/john-doe",
"links": [
{
"url": "http://google.com/",
"visits": 11000,
"last_visited": "2010-05-221T00:00:01Z"
\ No newline at end of file