vue json转yaml yaml转json 互转
方式一
npm install -save js-yaml
1.2、json转yaml
import yaml from 'js-yaml';
console.log("json转yaml",yaml.dump({ number: 3, plain: 'string', block: 'two\nlines\n' }))
1.2、yaml转json
import yaml from 'js-yaml';
const aaa = `---
apiVersion: v1
data:
tls.crt: c2Rhc2Q=
tls.key: YXNkYXNk
immutable: false
kind: Secret
metadata:
name: aaa
namespace: default
resourceVersion: '188835969'
type: kubernetes.io/tls`
console.log("yaml转json",yaml.load(aaa))
方式二
2.1、安装包
npm install -save yaml
2.2、json转yaml
import YAML from 'yaml'
console.log("json转yaml",YAML.stringify({ number: 3, plain: 'string', block: 'two\nlines\n' }))
2.3、yaml转json
import YAML from 'yaml'
const aaa = `---
apiVersion: v1
data:
tls.crt: c2Rhc2Q=
tls.key: YXNkYXNk
immutable: false
kind: Secret
metadata:
name: aaa
namespace: default
resourceVersion: '188835969'
type: kubernetes.io/tls`
console.log("yanl转json",YAML.parse(aaa))
版权声明:
作者:Akiraka
链接:https://www.akiraka.net/code/vue/1403.html
来源:Akiraka
文章版权归作者所有,未经允许请勿转载。
THE END
0
二维码
海报
vue json转yaml yaml转json 互转
方式一
npm install -save js-yaml
1.2、json转yaml
import yaml from 'js-yaml';
console.log("json转yaml",yaml.dump({ number: 3, ……
文章目录
关闭
共有 0 条评论