to_json and polymorphic models

I have tried to use to_json to create an array that will be
manipulated in javascript on the client. The output of to_json looks
something like this:

  {attributes: {code: "123123123", quantity: "123", id: "1",
description: "Window", unit_price: "12"}},
   attributes: {addressable_type: "WorkshopOrderPart",
workshop_order_id: "1", addressable_id: "1", id: "1", position:
{addressable: ...

You will notice that "attibutes" shows up twice due to the polymorphic
relationship but is not a range so if you assign it to a javascript
array then addressing it goes like this:


That works but:


does not. Anyone know how to go about addressing the "attributes"?