內容

名稱

json_pp - JSON::PP 命令工具

語法

json_pp [-v] [-f from_format] [-t to_format] [-json_opt options_to_json1[,options_to_json2[,...]]]

說明

json_pp 在一些輸入和輸出格式之間進行轉換(其中之一是 JSON)。此程式從 json_xs 複製並修改。

預設輸入格式為 json,預設輸出格式為具有漂亮選項的 json。

選項

-f

-f from_format

從 STDIN 讀取給定格式的資料。

格式類型

json

作為 JSON

eval

作為 Perl 程式碼

-t

將給定格式的資料寫入 STDOUT。

null

不執行任何動作。

json

作為 JSON

dumper

作為 Data::Dumper

-json_opt

JSON::PP 的選項

可接受的選項為

ascii latin1 utf8 pretty indent space_before space_after relaxed canonical allow_nonref
allow_singlequote allow_barekey allow_bignum loose escape_slash indent_length

多個選項必須以逗號分隔

Right: -json_opt pretty,canonical

Wrong: -json_opt pretty -json_opt canonical

-v

詳細選項,但目前實際上沒有動作。

-V

列印版本並結束。

範例

$ perl -e'print q|{"foo":"あい","bar":1234567890000000000000000}|' |\
   json_pp -f json -t dumper -json_opt pretty,utf8,allow_bignum

$VAR1 = {
          'bar' => bless( {
                            'value' => [
                                         '0000000',
                                         '0000000',
                                         '5678900',
                                         '1234'
                                       ],
                            'sign' => '+'
                          }, 'Math::BigInt' ),
          'foo' => "\x{3042}\x{3044}"
        };

$ perl -e'print q|{"foo":"あい","bar":1234567890000000000000000}|' |\
   json_pp -f json -t dumper -json_opt pretty

$VAR1 = {
          'bar' => '1234567890000000000000000',
          'foo' => "\x{e3}\x{81}\x{82}\x{e3}\x{81}\x{84}"
        };

另請參閱

JSON::PPjson_xs

作者

Makamaka Hannyaharamitu,<makamaka[at]cpan.org>

版權和授權

版權所有 2010 Makamaka Hannyaharamitu

此函式庫是免費軟體;您可以在與 Perl 相同的條款下重新散布或修改它。