json - 如何在yaml中的对象内嵌套数组?
问题描述
假设您Map<String, Object>
在 YAML 中有一个名为“某物”
something:
对应的 JSON 应该是这样的: json
"something": {
"else": "then",
"array": [
"element in array"
]
}
所以对于这个 yaml 规范可能是:
something:
else: then
array:
- element in array
但既然something
是地图,它不会让我做
array:
- element in array
或这个
array: ['element in array']
所以问题是 yaml 应该是什么来获得上述 JSON 考虑something
是否有Map<String, Object>
可能?
这是关于 ServiceCatalogDefinition 的定义,用于实现 OpenServiceBroker API。
我正在尝试根据需要制作上述链接中架构中提到的“属性”。为此,我需要让它像这样返回 json:
"properties" : {
"someProperty" : {
"description": "description",
"type": "string"
},
"required": [
"someProperty"
]
}
yaml 在我的 application.yml 中进行验证,抛出评论中提到的错误
解决方案
使用站点json2yaml,您将获得 YAML :
---
something:
else: then
array:
- element in array
来自 json :
{
"something": {
"else": "then",
"array": [
"element in array"
]
}
}
与您相比,我认为您的“-”必须与“array”处于同一级别。
推荐阅读
- azure-active-directory - Azure 广告 - Powershell - 如果用户是组 b 的成员,则从组 a 中删除用户
- libreoffice - 如何通过 Calc Macro 以编程方式打开和修改 ODT 文件
- java - 如何检查文件或控制台是否与标准输出相关联?
- postgresql - 每个函数/过程的 Postgres 日志目标
- python - Django 在注册表单中使用选择选项.py
- c - 循环缓冲区在第 6 个元素之后没有给出正确的缓冲区大小
- php - php 致命错误:require_once(): 无法打开所需的 'C:\xampp\htdocs\paribibi/public/index.php' (include_path='C:\xampp\php\PEAR')
- java - 我正在尝试在 Android Studio 中创建一个 Spinner
- ffmpeg - 调整覆盖视频的大小
- javascript - 如何使用 jQuery 使一个选定的选项颜色不同?