Ejemplos
See exactly how YAML block styles change a build notification
Compare a retained newline, a stripped newline and a folded space in one useful message.
Entrada
clip: |
Build passed.
strip: |-
Build passed.
fold: >-
Build
passed.
Expected answer
JSON{
"clip": "Build passed.\n",
"strip": "Build passed.",
"fold": "Build passed."
}{
"clip": "Build passed.\n",
"strip": "Build passed.",
"fold": "Build passed."
}Expand a shared YAML server configuration into JSON
Show the expanded data; JSON does not preserve YAML anchor notation or object-reference syntax.
Entrada
primary: &server
host: api.example.com
port: 443
backup: *server
Expected answer
JSON{
"primary": {
"host": "api.example.com",
"port": 443
},
"backup": {
"host": "api.example.com",
"port": 443
}
}{
"primary": {
"host": "api.example.com",
"port": 443
},
"backup": {
"host": "api.example.com",
"port": 443
}
}A support ticket with a zero-prefixed identifier
Entrada
{"ticket":"00123","priority":"high"}Expected answer
JSON{
"ticket": "00123",
"priority": "high"
}{
"ticket": "00123",
"priority": "high"
}An observatory reading with a negative temperature
Entrada
{"station":"demo-observatory","temperatureC":-12.5,"open":false}Expected answer
JSON{
"station": "demo-observatory",
"temperatureC": -12.5,
"open": false
}{
"station": "demo-observatory",
"temperatureC": -12.5,
"open": false
}A café menu with Unicode and a decimal price
Entrada
{"item":"café","price":3.5,"currency":"EUR"}Expected answer
JSON{
"item": "café",
"price": 3.5,
"currency": "EUR"
}{
"item": "café",
"price": 3.5,
"currency": "EUR"
}A safe webhook retry policy
Entrada
{"timeoutMs":5000,"retries":2,"enabled":true}Expected answer
JSON{
"timeoutMs": 5000,
"retries": 2,
"enabled": true
}{
"timeoutMs": 5000,
"retries": 2,
"enabled": true
}An image manifest with a null caption
Entrada
{"width":640,"height":480,"caption":null}Expected answer
JSON{
"width": 640,
"height": 480,
"caption": null
}{
"width": 640,
"height": 480,
"caption": null
}A release note with an embedded newline
Entrada
{"version":"2.1.0","notes":"Fixed parser\nAdded tests"}Expected answer
JSON{
"version": "2.1.0",
"notes": "Fixed parser\nAdded tests"
}{
"version": "2.1.0",
"notes": "Fixed parser\nAdded tests"
}An empty search result
Entrada
{"results":[],"total":0}Expected answer
JSON{
"results": [],
"total": 0
}{
"results": [],
"total": 0
}YAML to JSON
Entrada
number: 3
plain: string
block: |
two
linesExpected answer
JSON{
"number": 3,
"plain": "string",
"block": "two\nlines\n"
}{
"number": 3,
"plain": "string",
"block": "two\nlines\n"
}