@notes.to_json outputs=> [
{attributes: {title: "My Shiny New Box", individual_id: "1",
id: "1",
note: "The first of many such things"}},
{attributes: {title: "A second box", individual_id: "2", id:
"2",
note: "This is the second in a series of notes describing a box"}}
]
The keys (e.g. title:) are not quoted. I see this on my local dev and
on the main server.
Feeding this string back through the JSON::parser.decode(jsonstring)
fails with an ''unexpected token'' error.
Quoting the keys works fine.
An example json string from Wikipedia shows the keys quoted:
{
    "firstName": "John",
    "lastName": "Smith",
    "address": {
        "streetAddress": "21 2nd Street",
        "city": "New York",
        "state": "NY",
        "postalCode": 10021
    },
    "phoneNumbers": [
        "212 732-1234",
        "646 123-4567"
    ]
}
The code in the controller is:
   def index
    @notes = Note.find(:all)
    respond_to do |format|
      format.html # index.rhtml
      format.xml  { render :xml => @notes.to_xml }
      format.json  { render :json => @notes.to_json }
    end
  end
Am I missing something?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---