码迷,mamicode.com
首页 > Web开发 > 详细

jsonnet,就这么神奇

时间:2020-03-19 21:35:45      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:https   mint   die   init   alt   c++   html   jit   nis   

既然要玩kube-prometheus,

jsonnet,也附带着玩玩啦。。

https://jsonnet.org/learning/tutorial.html

我用的是Golang来玩的,不是C++版本的。

https://github.com/google/go-jsonnet

 

example.jsonnet

// A regular definition.
local house_rum = ‘Banks Rum‘;

{
  // A definition next to fields.
  local pour = 1.5,

  Daiquiri: {
    ingredients: [
      { kind: house_rum, qty: pour },
      { kind: ‘Lime‘, qty: 1 },
      { kind: ‘Simple Syrup‘, qty: 0.5 },
    ],
    served: ‘Straight Up‘,
  },
  Mojito: {
    ingredients: [
      {
        kind: ‘Mint‘,
        action: ‘muddle‘,
        qty: 6,
        unit: ‘leaves‘,
      },
      { kind: house_rum, qty: pour },
      { kind: ‘Lime‘, qty: 0.5 },
      { kind: ‘Simple Syrup‘, qty: 0.5 },
      { kind: ‘Soda‘, qty: 3 },
    ],
    garnish: ‘Lime wedge‘,
    served: ‘Over crushed ice‘,
  },
}

  

命令:

jsonnet.exe example.jsonnet

输出

技术图片

{
   "Daiquiri": {
      "ingredients": [
         {
            "kind": "Banks Rum",
            "qty": 1.5
         },
         {
            "kind": "Lime",
            "qty": 1
         },
         {
            "kind": "Simple Syrup",
            "qty": 0.5
         }
      ],
      "served": "Straight Up"
   },
   "Mojito": {
      "garnish": "Lime wedge",
      "ingredients": [
         {
            "action": "muddle",
            "kind": "Mint",
            "qty": 6,
            "unit": "leaves"
         },
         {
            "kind": "Banks Rum",
            "qty": 1.5
         },
         {
            "kind": "Lime",
            "qty": 0.5
         },
         {
            "kind": "Simple Syrup",
            "qty": 0.5
         },
         {
            "kind": "Soda",
            "qty": 3
         }
      ],
      "served": "Over crushed ice"
   }
}

  

jsonnet,就这么神奇

标签:https   mint   die   init   alt   c++   html   jit   nis   

原文地址:https://www.cnblogs.com/aguncn/p/12527263.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!