1
votes

Is there any way to define arrays on EmberJS models? I saw some posts using Transformation but those approaches don't achieve the results I need.

This is the (json) model I'm trying to represent:

{
    "category" : "Category 1",
    "subcategories" : [
        {
            "name" : "subcategory1",
            "value" : 210
        },
        {
            "name" : "subcategory2",
            "value" : 220
        }
    ]
},
{
    "category" : "Category 2",
    "subcategories" : [
        {
            "name" : "subcategory21",
            "value" : 250
        },
        {
            "name" : "subcategory22",
            "value" : 270
        }
    ]
}

I read about the hasMany method but I understand that it's only for relationships. If so, how can I represent that example json as ember model?

Thanks for the help!

1

1 Answers