JBuilder dynamic keys for model attributes
I'm trying to build a JSON file to access a product's variation via a variation code. Ideally, I could call variations.abcdefgh essentially asking to define a structure like this: { "variations":{ "abcdefgh":{ "available":true, "price":"12.00" }, "ijklmnop":{ "available":false, "price":"25.00" } } } Doing something in products/show.json.jbuilder like json.variations @product.variations gives me formatting as such: { "variations":[ { "available":true, "price":"12.00", "product_code":"abcdefgh" }, { "available":true, "price":"25.00", "product_code":"ijklmnop" } ] } maybe my JavaScript could be