YAML 中的多级嵌套 [英] Multiple level nesting in YAML

查看:63
本文介绍了YAML 中的多级嵌套的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 YAML 创建应用程序中使用的所有存储过程的列表以及调用它们的位置.我设想了类似下面的内容,但我认为 YAML 不允许多级嵌套.

I'm trying to use YAML to create list of all stored procs used in an application and from where they are called. I envisioned something like below but I think YAML does not allow multiple level nesting.

access_log:
  stored_proc: getsomething
    uses:
      usedin: some->bread->crumb
      usedin: something else here
  stored_proc: anothersp
    uses:
      usedin: blahblah

reporting:
  stored_proc: reportingsp
    uses:
      usedin: breadcrumb

有没有办法在 YAML 中做到这一点,如果没有,还有哪些其他选择?

Is there a way to do this in YAML and if not, what other alternatives are there?

推荐答案

这正是我在 YAML 中为 perl 脚本的配置文件使用嵌套级别的方式.本 YAML 教程 可能是您如何处理结构的很好参考想要 Ruby.

That's exactly how I've used nested levels in YAML for configuration files for perl scripts. This YAML Tutorial might be a good reference for you on how to handle the structure you want in Ruby.

我认为您的问题是试图混合类型.我建议这样修改:

I think your problem is trying to mix types. I suggest revising like this:

reporting:
  stored_procs:
    reportingsp
      uses:
        usedin: breadcrumb
    secondProc
      uses:
        usedin: something_else

这篇关于YAML 中的多级嵌套的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆