# Model JSON response

**URL:** <https://forums.kodeco.com/t/model-json-response/55281>\
**Category:** Server Side Swift with Vapor\
**Created:** [November 12, 2018, 7:22pm UTC](https://forums.kodeco.com/t/model-json-response/55281 "2018-11-12T19:22:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![frasco](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@frasco](https://forums.kodeco.com/u/frasco)\
**Post date:** [November 12, 2018, 7:22pm UTC](https://forums.kodeco.com/t/model-json-response/55281/1 "2018-11-12T19:22:19Z")

</div>

Hi,

Similar to [Modeling complex JSON](https://forums.kodeco.com/t/modeling-complex-json/44851) topic, I have the next Model on my project:

```
final class Colegio: Codable {
var id: UUID?
var nombre: String
var codigoMaestro: String?
var rutaLogo: String?
var logo: String
}

```

In my controller, I have the next struct and function, which works correctly:  
// WS para devolver relación de colegios  
func colegiosHandler( \_ req: Request) throws → Future\<[ColegiosData]\> {  
return Colegio.query(on: req).decode(data: ColegiosData.self).all()  
}

```
struct ColegiosData: Content {
let id: UUID
let nombre: String
let rutaLogo: String
}

```

What I want is that my web service returns the “id” property, but mapped with the codigoMaestro of my Model. I mean:  
nombre = “Colegio”  
rutaLogo = “Ruta al logo”  
id = “Código del maestro”

It is possible to do this?

Thanks in advance!  
Fran

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [November 12, 2018, 7:24pm UTC](https://forums.kodeco.com/t/model-json-response/55281/2 "2018-11-12T19:24:42Z")

</div>

@0xtim Can you please help with this when you get a chance? Thank you - much appreciated! :]

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [November 20, 2018, 1:33pm UTC](https://forums.kodeco.com/t/model-json-response/55281/3 "2018-11-20T13:33:55Z")

</div>

@frasco - the best way to do that would be to combine a join and `CodingKeys` to set the key. Docs on Joins are [here](https://github.com/raywenderlich/vapor-til/blob/master/Tests/AppTests/AcronymTests.swift#L50)
