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

YAML About 1,377 words

|

保留文本块中的换行符。

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"
}
Views: 6,102 · Posted: 2022-09-17

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

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

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


Today On History
Browsing Refresh