JSONNET ,Google 提供的一种新的 Json 转换工具,也是 JSON 的超集

JSON ,Java 语言处理非常多的格式。

尤其,在 API 接口数据交换方面更是大规模的采用了。

如何更好的处理 JSON ,Google 提供了一个全新的解决方案: JSONNET 。

https://github.com/google/jsonnet

brew install jsonnet           // 安装

入口站点 Jsonnet - Jsonnet Configuration Language

A configuration language for app and tool developers

  • Generate config data
  • Side-effect free
  • Organize, simplify, unify
  • Manage sprawling config

A simple extension of JSON

  • Open source (Apache 2.0)
  • Familiar syntax
  • Reformatter, linter
  • Editor & IDE integrations
  • Formally specified

JSONNET , 1

// Edit me!
{
  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!"
  }
}

JSONNET , 2 

// A function that returns an object.
local Person(name='Alice') = {
  name: name,
  welcome: 'Hello ' + name + '!',
};
{
  person1: Person(),
  person2: Person('Bob'),
}

JSON

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

参 考

JSON

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值