# How do I map JSON data with my model?

**URL:** <https://discuss.emberjs.com/t/how-do-i-map-json-data-with-my-model/16383>\
**Category:** Ember Data\
**Created:** [April 1, 2019, 3:37am UTC](https://discuss.emberjs.com/t/how-do-i-map-json-data-with-my-model/16383 "2019-04-01T03:37:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tem\_Codo](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/tem_codo/32/16400_2.png) [@Tem\_Codo](https://discuss.emberjs.com/u/Tem_Codo)\
**Post date:** [April 1, 2019, 3:37am UTC](https://discuss.emberjs.com/t/how-do-i-map-json-data-with-my-model/16383/1 "2019-04-01T03:37:00Z")

</div>

I am using Ember Data but I have problem how to map it with my model.

This is my JSON api look like.

 ![09%20AM](https://us1.discourse-cdn.com/flex019/uploads/emberjs_public/original/3X/6/4/64a355ce711a454914ea4bd3261e7efc56b12bac.png)

What I want to map with my model is in the **attributes** field

Can you help me to guide from beginning how to fetch data from server until render it, please.

Thank you very much

---

<div class="post-metadata">

**Author:** ![NullVoxPopuli](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/nullvoxpopuli/32/18691_2.png) [@NullVoxPopuli](https://discuss.emberjs.com/u/NullVoxPopuli)\
**Post date:** [April 1, 2019, 1:11pm UTC](https://discuss.emberjs.com/t/how-do-i-map-json-data-with-my-model/16383/2 "2019-04-01T13:11:05Z")

</div>

your model should look something like this:

```nohighlight
export default class Post extends Model {
  @attr() name;
  @attr() priceFixed;
  // etc

  @belongsTo() gallery;
  @belongsTo() currency;
}

```

run this in the terminal to get your model class:

```bash
ember g model post

```

and it looks like you’re using `{json:api}`, so, you’ll want to make sure your adapter inherits from `JSONAPIAdapter` and the serializer inherits from `JSONAPISerializer`

This may be of interest to you: [Defining Models - Ember Data - Ember Guides](https://guides.emberjs.com/release/models/defining-models/)

I don’t know how well you know ember / how new you are, so if you need more detail, feel free to ask 🙂

---

<div class="post-metadata">

**Author:** ![Tem\_Codo](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/tem_codo/32/16400_2.png) [@Tem\_Codo](https://discuss.emberjs.com/u/Tem_Codo)\
**Post date:** [April 2, 2019, 7:02am UTC](https://discuss.emberjs.com/t/how-do-i-map-json-data-with-my-model/16383/3 "2019-04-02T07:02:11Z")

</div>

Thank you very much Sir, Yes I am new to Ember and I can get data from API and already pass to template ( **hbs** ) files.

My problem is when I try to loop through in template file, i need to use it like this

```
    {{#each model as |product|}}
        <h4>Pro: {{product.attibutes.name}}</h4>
    {{/each}}

```

And this seem to be not the same as my model. And in my model I have to have a field call **attributes** and it seem not correct way to do it. What should I do?

---

<div class="post-metadata">

**Author:** ![NullVoxPopuli](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/nullvoxpopuli/32/18691_2.png) [@NullVoxPopuli](https://discuss.emberjs.com/u/NullVoxPopuli)\
**Post date:** [April 2, 2019, 10:16am UTC](https://discuss.emberjs.com/t/how-do-i-map-json-data-with-my-model/16383/4 "2019-04-02T10:16:04Z")

</div>

You should be able to access ‘name’ on the product 😉

Can you share your model?

---

<div class="post-metadata">

**Author:** ![Tem\_Codo](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/tem_codo/32/16400_2.png) [@Tem\_Codo](https://discuss.emberjs.com/u/Tem_Codo)\
**Post date:** [April 3, 2019, 3:08am UTC](https://discuss.emberjs.com/t/how-do-i-map-json-data-with-my-model/16383/5 "2019-04-03T03:08:09Z")

</div>

Yes can.

But now I found solutions. Thank you very much sir.

---

<div class="post-metadata">

**Author:** ![James-Byrne](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/james-byrne/32/17391_2.png) [@James-Byrne](https://discuss.emberjs.com/u/James-Byrne)\
**Post date:** [April 3, 2019, 8:52am UTC](https://discuss.emberjs.com/t/how-do-i-map-json-data-with-my-model/16383/6 "2019-04-03T08:52:48Z")

</div>

If you get a chance could you post your solution? Others might find it super helpful later on 😄
