JsonNet-PHP 是 Google Jsonnet 对 PHP的支持扩展.
pecl: http://pecl.php.net/package/jsonnet
gitosc: http://git.oschina.net/ciogao/JsonNet
github: https://github.com/Neeke/JsonNet
Install Jsonnet-PHP扩展
1
2
3
|
The pecl package is : http: //pecl .php.net /package/jsonnet pecl install jsonnet |
Input (Jsonnet)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
{ 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)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
{ "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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
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 的详细介绍:请点这里
- JsonNet-PHP 的下载地址:请点这里
- JsonNet-PHP 的源码地址:http://git.oschina.net/ciogao/JsonNet
想通过手机客户端(支持 Android、iPhone 和 Windows Phone)访问开源中国:请点这里
本站文章除注明转载外,均为本站原创或编译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动共创开源社区
转载请注明:文章转载自:开源中国社区 [http://www.oschina.net]
本文标题:支持 JsonNet 的 PHP 扩展发布
本文地址:http://www.oschina.net/news/62953/jsonnet-php
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动共创开源社区
转载请注明:文章转载自:开源中国社区 [http://www.oschina.net]
本文标题:支持 JsonNet 的 PHP 扩展发布
本文地址:http://www.oschina.net/news/62953/jsonnet-php
全站熱搜
留言列表