> For the complete documentation index, see [llms.txt](https://docs.mburger.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mburger.cloud/sample-app-1/map-your-objects-from-mburger-objects.md).

# Map your objects from MBurger objects

{% hint style="info" %}
We are going to create an array of Home objects from the sections returned by the api.
{% endhint %}

The home objects will be like this:

{% tabs %}
{% tab title="iOS" %}

```java
class Home: NSObject {
    @objc var title: URL?
    @objc var homeDescription: String?
    @objc var images: [MBImage]?
}
```

Let’s add a mapping dictionary in Home like this, so that the section can map its elements to the Home object properties.

```java
static func mappingDictionary() -> [String: String] {
    return [“title”: “title”,
            “description”: “homeDescription”,
            “images”:“images”]
}
```

Now we have to create the array of homes from the `MBSections`. To do so, let’s add the following in the success block:

```java
self.homes = sections.map({ section -> Home in
                           let home = Home()
                           section.mapElements(to: home, withMapping: Home.mappingDictionary())
                           return home
                           }
```

{% hint style="success" %}
Now in the homes array we will have Homes objects created from the sections.&#x20;
{% endhint %}

We should do the same thing in the News and Gallery **viewcontrollers**, using different object models and a different mapping dictionary.
{% endtab %}

{% tab title="Android" %}

```java
public class Home implements Serializable {
    private String title, description;
    private MBImages images;
 
    public String getTitle() {
        return title;
    }
  
    public void setTitle(String title) {
        this.title = title;
    }
  
    public MBImages getImages() {
        return images;
    }
 
    public void setImages(MBImages images) {  
        this.images = images;
    }
 
    public String getDescription() {  
        return description;
    }
 
    public void setDescription(String description) {
        this.description = description;
    }
}
```

We use the `MBImages` class, which is a representation of images inside a section for convenience.

Now we need to map our `MBSection` objects to `Home` objects:

```java
public Home mapHome(MBSection section) {
   MBFieldsMapping fieldsMapping = new MBFieldsMapping();
   fieldsMapping.putMap(“title”, “title”);
   fieldsMapping.putMap(“images”, “image”);
   fieldsMapping.putMap(“description”, “description”);
   Home h = (Home) MBurgerMapper.mapToCustomObject(section, fieldsMapping, new Home(), false);
   return h;  
}
```

{% hint style="success" %}
Once we have an array of homes, we can show them creating our own custom UI using the Android SDK. We can then do the same procedure for the gallery and news screens.
{% endhint %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mburger.cloud/sample-app-1/map-your-objects-from-mburger-objects.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
