Google 的 Jsonnet

GoogleJSON 延伸發展出來的描述性語言,Jsonnet:「Jsonnet: a more elegant language for composing JSON」。

// Jsonnet Example
{
    person1: {
        name: "Alice",
        welcome: "Hello " + self.name + "!",
    },
    person2: self.person1 { name: "Bob" },
}

所對應的 JSON 會是:

{
   "person1": {
      "name": "Alice",
      "welcome": "Hello Alice!"
   },
   "person2": {
      "name": "Bob",
      "welcome": "Hello Bob!"
   }
}

可以透過 self 與運算做不少事情。不知道拿來當設定檔如何...

看日期推出一陣子了,去年八月就放出來了...

Leave a Reply

Your email address will not be published. Required fields are marked *