# YAML

**Content-Type: "application/x-yaml"**

**YAML** (a recursive acronym for "YAML Ain't Markup Language") is a human-readable data-serialization language. It is commonly used for **configuration** files and in applications where data is being stored or transmitted. YAML targets many of the same communications applications as Extensible Markup Language (XML) but has a minimal syntax which intentionally differs from [SGML](https://en.wikipedia.org/wiki/Standard_Generalized_Markup_Language).

The `Context.YAML(v)` is the method which sends YAML responses to the client. It accepts a value of any type. You only need the `yaml` struct field and all fields should be exported.

```go
type ExampleYAML struct {
	Name       string `yaml:"name"`
	ServerAddr string `yaml:"ServerAddr"`
}

func handler(ctx iris.Context) {
    response := ExampleYAML{Name: "Iris", ServerAddr: "localhost:8080"}
    ctx.YAML(response)
}
```

**Result**

```yaml
name: Iris
ServerAddr: localhost:8080
```

The same result can be achieved using `iris.Map` or a standard Go `map`:

```go
func handler(ctx iris.Context) {
    response := iris.Map{"name": "Iris", "serverAddr": "localhost:8080"}
    ctx.YAML(response)
}
```

References:

* [Wikipedia](https://en.wikipedia.org/wiki/YAML)
* [The Official YAML Web Site](https://yaml.org/)


---

# Agent Instructions: 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:

```
GET https://iris-go.gitbook.io/iris/responses/yaml.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
