Jsonnet-PHP Install Jsonnet-PHP扩展Input (Jsonnet)Demo of PHPPHP Re ResultCodeTips Jsonnet 的 PHP 扩展

程序名称:Jsonnet-PHP Install Jsonnet-PHP扩展Input (Jsonnet)Demo of PHPPHP Re ResultCodeTips

授权协议: Apache-2.0

操作系统: 跨平台

开发语言: C/C++

Jsonnet-PHP Install Jsonnet-PHP扩展Input (Jsonnet)Demo of PHPPHP Re ResultCodeTips 介绍

JsonNet-PHP 是 Google Jsonnet 对 PHP的支持扩展.

pecl: http://pecl.php.net/package/jsonnet

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

gitee: https://gitee.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",
        },
    }
}
{
    "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));

PHP Re Result

/usr/local/php/php-7.0.6-zts-debug/bin/php --re jsonnet

Extension [  extension #40 JsonNet version v1.3.0 ] {

  - Constants [2] {
    Constant [ string JSONNET_PHP_VERSION ] { v1.3.0 }
    Constant [ string JSONNET_PHP_AUTHOR ] { Chitao.Gao  [ neeke@php.net ] }
  }

  - Functions {
    Function [  function jsonnet_get_version ] {
    }
    Function [  function jsonnet_get_author ] {
    }
  }

  - Classes [1] {
    Class [  class JsonNet ] {

      - Constants [0] {
      }

      - Static properties [0] {
      }

      - Static methods [4] {
        Method [  static public method evaluateFile ] {

          - Parameters [1] {
            Parameter #0 [  $file_path ]
          }
        }

        Method [  static public method evaluateSnippet ] {

          - Parameters [1] {
            Parameter #0 [  $snippet_string ]
          }
        }

        Method [  static public method fmtFile ] {

          - Parameters [1] {
            Parameter #0 [  $file_path ]
          }
        }

        Method [  static public method fmtSnippet ] {

          - Parameters [1] {
            Parameter #0 [  $snippet_string ]
          }
        }
      }

      - Properties [0] {
      }

      - Methods [2] {
        Method [  public method __construct ] {
        }

        Method [  public method __destruct ] {
        }
      }
    }
  }
}

CodeTips

<?php
/**
 * @author neeke@php.net
 * Date: 18/3/29 下午7:51
 */

const JSONNET_PHP_VERSION = 'v1.3.0';
const JSONNET_PHP_AUTHOR  = 'neeke@php.net';

const CODE_SUCCESS = 1000;
const CODE_ERROR   = 900;

/**
 * @return string
 */
function jsonnet_get_version()
{
    return JSONNET_PHP_VERSION;
}

function jsonnet_get_author()
{
    return JSONNET_PHP_AUTHOR;
}

class JsonNet
{
    public function __construct()
    {
        #JsonNet init
    }

    public function __destruct()
    {
        #JsonNet destroy
    }

    /**
     * @param $file_path
     *
     * @return array
     * @throws Exception
     */
    static public function evaluateFile($file_path)
    {
        throw new Exception('JsonNet::evaluateFile #error', CODE_ERROR);

        return array();
    }

    /**
     * @param $snippet_string
     *
     * @return array
     * @throws Exception
     */
    static public function evaluateSnippet($snippet_string)
    {
        throw new Exception('JsonNet::evaluateSnippet #error', CODE_ERROR);

        return array();
    }

    /**
     * @param $file_path
     *
     * @return array
     * @throws Exception
     */
    static public function fmtFile($file_path)
    {
        throw new Exception('JsonNet::fmtFile #error', CODE_ERROR);

        return array();
    }

    /**
     * @param $snippet_string
     *
     * @return array
     * @throws Exception
     */
    static public function fmtSnippet($snippet_string)
    {
        throw new Exception('JsonNet::fmtSnippet #error', CODE_ERROR);

        return array();
    }

}

Jsonnet-PHP Install Jsonnet-PHP扩展Input (Jsonnet)Demo of PHPPHP Re ResultCodeTips 官网

https://gitee.com/neeke/Jsonnet-PHP

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


MuPlayer 是一款跨平台、轻量级的音频播放解决方案,是百度@音乐前端团队开发维护的浏览端音频播放内核,它基于HTML5
OS FLV 是一个 开源和可嵌入网页的flv播放器。 这个播放器拥有大量的选项可以通过嵌入代码进行设置.
DewPlayer音乐播放器,样式很简单,而且很实用.播放器可以根据自己的喜好改变颜色,也算比较个性化吧.但唯一的不足就是只支持MP3格式的音乐。
JW FLV MEDIA PLAYER是一个开源的在网页上使用的Flash视频、音频以及图片播放器,支持 Sliverlight
Speakker 是一个基于 Web 浏览器的音乐播放器,只提供很多高级播放功能包括播放列表管理和分享。
Player Framework 是一个开源的支持 HTML5 的视频播放器框架,同时也支持 Silverlight 和 Windows Phone
Sewise Player是一款专业的免费网页视频、流播放器,它功能强大,体积小,跨平台,使用方便简洁、随心所欲:
SoundManager 2 利用 HTML5 和 Flash 技术提供了稳定和阔平台的音乐播放功能,只有 10K 的 JS 包。
xPlayer v1.0 特性: 文件大小 9.78kb; 可以自定义皮肤; 3.支持 http 和 rtmp 视频; 4.音量调节,全屏播放,拖拽播放;
XPlayer 豆瓣音乐播放器 特点: 1.自动侦测Douban网页的歌曲 2.Douban网页关闭,歌曲能够继续播放
歌词 插件 最新更新,扩展性能稍微有点提升了, 不多说了,更多敬请查看首页http://luochunzong.sinaapp.com/?p=84
ABPlayerHTML5是一个在HTML5下的弹幕播放器(同步显示视频于评论)实现。类似功能的播放器可以参考基于Flash的MukioPlayer和PADPlayer。
AudioPlayer.js 是一个 jQuery 的插件,实现了 HTML5 的音乐播放器,无需任何图片,实现了响应式布局,支持触摸操作。
替换中国大陆主流视频网站的 Flash 播放器为 HTML5 播放器 使用 Mac 的同学都可能碰到过在线看视频引起机子风扇狂转、机身发烫等情况,这是因为 Flash 占用了过多系统资源的缘故。
AetherPlayer 是一个类CD的轻量HTML5播放器,特别适合博客及个人站点使用。它漂亮得不像……咳,这边吹牛的话就不说了。
专注、极致、智慧,国内外为数不多不依赖开源框架、跨平台(windows/android/iOS)、公网推送(支持rtmp)-播放(支持rtmp/rtsp)业界真正靠谱 的超低延迟。
node-kugou-client 是 Node.js 酷狗客户端。 安装 npm install node-kugou-client 使用 var kugou = require(\"node-kugou-client\");
Youku HTML5 播放器扩展 —— 告别 flash 和广告 关于官方内测 html5 播放器 Firefox ( xpi 直接安装) ( firefox 50.0+)
Chimee 由奇舞团研制的 h5 播放器,它支持 mp4、m3u8、flv 等多种格式。通过插件式开发,能满足业务方快速迭代、灰度发布等要求。让开发者能够轻松快捷地完成视频场景的开发。
OneVideo是一款基于OneBase+UniApp开发的小视频播放移动应用。