Jsonnet-PHPGoogle 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比较输出。然而,例如输出本页已被手动重新排序,以允许更容易的视觉对比给定输入。输出的空格也被调整以使它更适合放在页面。

Install Jsonnet-PHP扩展

The pecl package is :  HTTP://pecl.php.NET/package/jsonnet

pecl install jsonnet

Input (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",
        },
    }
}

Output (JSON)

{
    "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"
        }
    }
}

Demo of PHP

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));
Jsonnet-PHP v1.2.0 发布, PHP 支持 Jsonnet 扩展
Jsonnet-PHP v1.2.0发布了,JsonNet-PHP是Google Jsonnet对PHP的支持扩展,该版本使用最新版本至v0.9.5的LibJsonnet。pecl:  http://pecl.php.net/package/jsonnetgithub:  https://github.com/Neeke/Jsonnet-PHPChange Log: Fixed issue #4, pecl install failed.       &

发布于 2017-11-29 03:02:20 | 149 次阅读

Jsonnet-PHP v1.1.0 发布, PHP 的支持扩展
Jsonnet-PHP v1.1.0 发布了,JsonNet-PHP 是 Google Jsonnet 对 PHP的支持扩展,v1.1.0,使用最新版本至v0.8.9的LibJsonnet。pecl:  http://pecl.php.net/package/jsonnetgithub:  https://github.com/Neeke/Jsonnet-PHPChange Log:- Update Lib JsonNet use v0.8.9. - 

发布于 2016-07-14 10:19:08 | 160 次阅读


Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务