Jsonnet-PHP 是 Google JSONnet 对 PHP的支持扩展.
PECL: http://pecl.php.net/package/jsonnet
Github: https://github.com/Neeke/Jsonnet-PHP
Google Jsonnet TuTorial
jsonnet语言,从其最基本的功能,其强大的对象模型,并从鸡尾酒世界的例子。这些例子都是有趣的,虽然有点做作,不限制我们的思维,任何一个特定的应用jsonnet。
注意:注意jsonnet unparses JSON的一种简单方法。特别是,它按字母顺序排序的输出对象领域。这是自然的和兼容的JSON,因为如果顺序是有意义的,对一个数组应该用来代替一个物体。同时,unparsing JSON使用规范排序的字段名可以使用diff比较输出。然而,例如输出本页已被手动重新排序,以允许更容易的视觉对比给定输入。输出的空格也被调整以使它更适合放在页面。
The pecl package is : HTTP://pecl.php.NET/package/jsonnet pecl install jsonnet
{ cockTails: { // IngredIEnt quantities are in fluid ounces. "Tom Collins": { ingredients: [ { kind: "Farmers Gin", Qty: 1.5 }, { kind: "Lemon", qty: 1 }, { kind: "Simple Syrup", qty: 0.5 }, { kind: "Soda", qty: 2 }, { kind: "Angostura", qty: "Dash" }, ], garNish: "Maraschino Cherry", served: "Tall", }, Manhattan: { ingredients: [ { kind: "Rye", qty: 2.5 }, { kind: "Sweet Red Vermouth", qty: 1 }, { kind: "Angostura", qty: "dash" }, ], garnish: "Maraschino Cherry", served: "Straight Up", }, } }
{ "cocktails": { "Tom Collins": { "ingredients": [ { "kind": "Farmers Gin", "qty": 1.5 }, { "kind": "Lemon", "qty": 1 }, { "kind": "Simple Syrup", "qty": 0.5 }, { "kind": "Soda", "qty": 2 }, { "kind": "Angostura", "qty": "dash" } ], "garnish": "Maraschino Cherry", "served": "Tall" }, "Manhattan": { "ingredients": [ { "kind": "Rye", "qty": 2.5 }, { "kind": "Sweet Red Vermouth", "qty": 1 }, { "kind": "Angostura", "qty": "dash" } ], "garnish": "Maraschino Cherry", "served": "Straight Up" } } }
JsonNet::evaLuateFile('bar_menu.1.jsonnet'); $Snippet = ' { cocktails: { // Ingredient quantities are in fluid ounces. "Tom Collins": { ingredients: [ { kind: "Farmers Gin", qty: 1.5 }, { kind: "Lemon", qty: 1 }, { kind: "Simple Syrup", qty: 0.5 }, { kind: "Soda", qty: 2 }, { kind: "Angostura", qty: "dash" }, ], garnish: "Maraschino Cherry", served: "Tall", }, Manhattan: { ingredients: [ { kind: "Rye", qty: 2.5 }, { kind: "Sweet Red Vermouth", qty: 1 }, { kind: "Angostura", qty: "dash" }, ], garnish: "Maraschino Cherry", served: "Straight Up", }, } } '; var_dump(JsonNet::evaluateSnippet($Snippet));
发布于 2017-11-29 03:02:20 | 149 次阅读
发布于 2016-07-14 10:19:08 | 160 次阅读