Java OpenResty Spring Spring Boot MySQL Redis MongoDB PostgreSQL Linux Android Nginx 面试 小程序 Arthas JVM AQS juc Kubernetes Docker 诊断工具


YAML | 竖线 > 大于号 - 减号等特殊符号的作用

YAML 大约 1377 字

|

保留文本块中的换行符。

infoA: |
  this is my info
  my name is tom
  and I'm 18

输出JSON

{
  "infoA": "this is my info\nmy name is tom\nand I'm 18\n"
}

>

文本块中的换行替换为空格。

注意:会保留最后一行的换行符。

infoB: >
  this is my info
  my name is tom
  and I'm 18

输出JSON

{
  "infoB": "this is my info my name is tom and I'm 18\n"
}

|+

保留文本块最后一行的换行符。

>|默认最后一行有换行符,等于加了+

infoC: |+
  this is my info
  my name is tom
  and I'm 18

输出JSON

{
  "infoC": "this is my info\nmy name is tom\nand I'm 18\n"
}

|-

删除字符串最后一行的换行符。

infoD: |-
  this is my info
  my name is tom
  and I'm 18

输出JSON

{
  "infoD": "this is my info\nmy name is tom\nand I'm 18"
}

>-

文本块中的换行替换为空格。-减号会删除最后一行的换行符。

infoE: >
  this is my info
  my name is tom
  and I'm 18

输出JSON

{
  "infoE": "this is my info my name is tom and I'm 18"
}

示例

infoA: |
  this is my info
  my name is tom
  and I'm 18
infoB: >
  this is my info
  my name is tom
  and I'm 18
infoC: |+
  this is my info
  my name is tom
  and I'm 18
infoD: |-
  this is my info
  my name is tom
  and I'm 18
infoE: >
  this is my info
  my name is tom
  and I'm 18

转为JSON

{
  "infoA": "this is my info\nmy name is tom\nand I'm 18\n",
  "infoB": "this is my info my name is tom and I'm 18\n",
  "infoC": "this is my info\nmy name is tom\nand I'm 18\n",
  "infoD": "this is my info\nmy name is tom\nand I'm 18",
  "infoE": "this is my info my name is tom and I'm 18"
}
阅读 2797 · 发布于 2022-09-17

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb

扫描下方二维码关注公众号和小程序↓↓↓

扫描二维码关注我
昵称:
随便看看 换一批