Jsonnet-PHP Jsonnet 的 PHP 扩展开源项目

我要开发同款
匿名用户2015年06月01日
84阅读

技术信息

开源地址
https://gitee.com/neeke/Jsonnet-PHP
授权协议
Apache-2.0

作品详情

JsoNet-PHP是GoogleJsoet 对 PHP的支持扩展.

pecl: https://pecl.php.et/package/jsoet

github: https://github.com/Neeke/Jsoet-PHP

gitee:https://gitee.com/eeke/Jsoet-PHP

GoogleJsoetTutorial

jsoet语言,使用其提供的基本函数功能,拥有了强大的对象模型,可以从混合的描述中描绘出对象。这些例子都是有趣的,虽然有点不自然,请不要从现有的例子来限制我们的思维,或以为jsoet只能作这些特定的应用。注意:注意jsoetuparsesJSON的一种简单方法。特别是,它按字母顺序排序的输出对象领域。这是自然的和兼容的JSON,因为如果顺序是有意义的,对一个数组应该用来代替一个物体。同时,uparsigJSON使用规范排序的字段名可以使用diff比较输出。然而,例如输出本页已被手动重新排序,以允许更容易的视觉对比给定输入。输出的空格也被调整以使它更适合放在页面。

IstallJsoet-PHP扩展The pecl package is :  https://pecl.php.et/package/jsoetpecl istall jsoetIput(Jsoet){    cocktails: {        // Igrediet quatities are i fluid ouces.        "Tom Collis": {            igrediets: [                { kid: "Farmers Gi", qty: 1.5 },                { kid: "Lemo", qty: 1 },                { kid: "Simple Syrup", qty: 0.5 },                { kid: "Soda", qty: 2 },                { kid: "Agostura", qty: "dash" },            ],            garish: "Maraschio Cherry",            served: "Tall",        },        Mahatta: {            igrediets: [                { kid: "Rye", qty: 2.5 },                { kid: "Sweet Red Vermouth", qty: 1 },                { kid: "Agostura", qty: "dash" },            ],            garish: "Maraschio Cherry",            served: "Straight Up",        },    }}Output(JSON){    "cocktails": {        "Tom Collis": {            "igrediets": [                { "kid": "Farmers Gi", "qty": 1.5 },                { "kid": "Lemo", "qty": 1 },                { "kid": "Simple Syrup", "qty": 0.5 },                { "kid": "Soda", "qty": 2 },                { "kid": "Agostura", "qty": "dash" }            ],            "garish": "Maraschio Cherry",            "served": "Tall"        },        "Mahatta": {            "igrediets": [                { "kid": "Rye", "qty": 2.5 },                { "kid": "Sweet Red Vermouth", "qty": 1 },                { "kid": "Agostura", "qty": "dash" }            ],            "garish": "Maraschio Cherry",            "served": "Straight Up"        }    }}DemoofPHPJsoNet::evaluateFile('bar_meu.1.jsoet');    $Sippet = '    {        cocktails: {            // Igrediet quatities are i fluid ouces.            "Tom Collis": {                igrediets: [                    { kid: "Farmers Gi", qty: 1.5 },                    { kid: "Lemo", qty: 1 },                    { kid: "Simple Syrup", qty: 0.5 },                    { kid: "Soda", qty: 2 },                    { kid: "Agostura", qty: "dash" },                ],                garish: "Maraschio Cherry",                served: "Tall",            },            Mahatta: {                igrediets: [                    { kid: "Rye", qty: 2.5 },                    { kid: "Sweet Red Vermouth", qty: 1 },                    { kid: "Agostura", qty: "dash" },                ],                garish: "Maraschio Cherry",                served: "Straight Up",            },        }    }    ';    var_dump(JsoNet::evaluateSippet($Sippet));PHPReResult/usr/local/php/php-7.0.6-zts-debug/bi/php --re jsoetExtesio [  extesio #40 JsoNet versio v1.3.0 ] {  - Costats [2] {    Costat [ strig JSONNET_PHP_VERSION ] { v1.3.0 }    Costat [ strig JSONNET_PHP_AUTHOR ] { Chitao.Gao  [ eeke@php.et ] }  }  - Fuctios {    Fuctio [  fuctio jsoet_get_versio ] {    }    Fuctio [  fuctio jsoet_get_author ] {    }  }  - Classes [1] {    Class [  class JsoNet ] {      - Costats [0] {      }      - Static properties [0] {      }      - Static methods [4] {        Method [  static public method evaluateFile ] {          - Parameters [1] {            Parameter #0 [  $file_path ]          }        }        Method [  static public method evaluateSippet ] {          - Parameters [1] {            Parameter #0 [  $sippet_strig ]          }        }        Method [  static public method fmtFile ] {          - Parameters [1] {            Parameter #0 [  $file_path ]          }        }        Method [  static public method fmtSippet ] {          - Parameters [1] {            Parameter #0 [  $sippet_strig ]          }        }      }      - Properties [0] {      }      - Methods [2] {        Method [  public method __costruct ] {        }        Method [  public method __destruct ] {        }      }    }  }}CodeTips<?php/** * @author eeke@php.et * Date: 18/3/29 下午7:51 */cost JSONNET_PHP_VERSION = 'v1.3.0';cost JSONNET_PHP_AUTHOR  = 'eeke@php.et';cost CODE_SUCCESS = 1000;cost CODE_ERROR   = 900;/** * @retur strig */fuctio jsoet_get_versio(){    retur JSONNET_PHP_VERSION;}fuctio jsoet_get_author(){    retur JSONNET_PHP_AUTHOR;}class JsoNet{    public fuctio __costruct()    {        #JsoNet iit    }    public fuctio __destruct()    {        #JsoNet destroy    }    /**     * @param $file_path     *     * @retur array     * @throws Exceptio     */    static public fuctio evaluateFile($file_path)    {        throw ew Exceptio('JsoNet::evaluateFile #error', CODE_ERROR);        retur array();    }    /**     * @param $sippet_strig     *     * @retur array     * @throws Exceptio     */    static public fuctio evaluateSippet($sippet_strig)    {        throw ew Exceptio('JsoNet::evaluateSippet #error', CODE_ERROR);        retur array();    }    /**     * @param $file_path     *     * @retur array     * @throws Exceptio     */    static public fuctio fmtFile($file_path)    {        throw ew Exceptio('JsoNet::fmtFile #error', CODE_ERROR);        retur array();    }    /**     * @param $sippet_strig     *     * @retur array     * @throws Exceptio     */    static public fuctio fmtSippet($sippet_strig)    {        throw ew Exceptio('JsoNet::fmtSippet #error', CODE_ERROR);        retur array();    }}

功能介绍

JsonNet-PHP 是 Google Jsonnet 对 PHP的支持扩展. pecl: http://pecl.php.net/package/jsonnet github: https:...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论