uspTukubaiコマンドに関する様々な資料がここにあります。

 

 

魂内検索

DOCUMENTS

COMMAND

FORUM

UEC DOCS

VIDEO

 

Alphabetical list

(Video materials in preparation)

wjson(USP)

Name

wjson : convert data in field format into JSON data.

Synopsis

Usage   : wjson [-p<c>][-m<c>][-s<c>][-n<string>] <field-file>

          --null

          --truefalse

Version : Tue Sep  7 15:06:54 JST 2021

Edition : 2

Description

Converts field format data into JSON data (RFC8259).

Names in key positions are separated with ".", numbers mean indices of

an array and other strings mean keys of objects.

Conversions into JSON are performed following a hierarchical structure

of key positions.

Options

-p : changes the sepaerator of the key name. "." is the default.

-m : changes the alternative character of white space in a key name.

     "_" is the default.

-s : changes the alternative character of white space in a value.

     "_" is the default.

-n : changes the padding string of a value. "_" is the default.

--null       : changes the alternative string of a blank string into

               null. A raw "null" will be printed.

--truefalse  : prints "true" as raw true" literal and "false" as raw

               false literal without quotations respectively.

Remark

The following characters in a value will be escaped as follows.

  A double quotation(") -> \"

  A backslash (\)       -> \\

  A slash (/)           -> \/

Example 1

$ cat fielddata

1.name Alice_Brown

1.sku 54321

1.price 199.95

1.shipTo.name Bob_Brown

1.shipTo.address 456_Oak_Lane

1.shipTo.city Pretendville

1.shipTo.state _

1.shipTo.zip 98999

1.billTo.name Alice_Brown

1.billTo.address 456_Oak_Lane

1.billTo.city Pretendville

1.billTo.state HI

1.billTo.zip 98999

2.name Donald_Tramp

2.sku 24680

2.price 153.32

2.shipTo.name Kim_Jonil

2.shipTo.address 123_Hidroask

2.shipTo.city Pyonyan

2.shipTo.state NK

2.shipTo.zip 10012

2.billTo.name Donald_Tramp

2.billTo.address 456_Oak_Lane

2.billTo.city Pretendville

2.billTo.state HI

2.billTo.zip 98999

$ wjson < fielddata

[

        {

        "name":"Alice Brown",

        "sku":54321,

        "price":199.95,

        "shipTo":{

                "name":"Bob Brown",

                "address":"456 Oak Lane",

                "city":"Pretendville",

                "state":"",

                "zip":98999

                },

        "billTo":{

                "name":"Alice Brown",

                "address":"456 Oak Lane",

                "city":"Pretendville",

                "state":"HI",

                "zip":98999

                }

        },

        {

        "name":"Donald Tramp",

        "sku":24680,

        "price":153.32,

        "shipTo":{

                "name":"Kim Jonil",

                "address":"123 Hidroask",

                "city":"Pyonyan",

                "state":"NK",

                "zip":10012

                },

        "billTo":{

                "name":"Donald Tramp",

                "address":"456 Oak Lane",

                "city":"Pretendville",

                "state":"HI",

                "zip":98999

                }

        }

]

Example 2

$ cat fielddata2

1.1 a

1.2 b

2.1 c

2.2 d

$ wjson fielddata2

[

        [

        "a",

        "b"

        ],

        [

        "c",

        "d"

        ]

]

Example 3

$ cat fielddata3

year 2013

title Turn_It_Down,_Or_Else!

info.directors.1 Alice_Smith

info.directors.2 Bob_Jones

info.release_date 2013-01-18T00:00:00Z

info.rating 6.2

info.genres.1 Comedy

info.genres.2 Drama

info.image_url http://ia.media-imdb.com/images/N/O9ERWAU7FS797AJ7LU8HN09AMUP908RLlo5JF90EWR7LJKQ7@@._V1_SX400_.jpg

info.plot A_rock_band_plays_their_music_at_high_volumes,_annoying_the_neighbors.

info.rank 11

info.running_time_secs 5215

info.actors.1 David_Matthewman

info.actors.2 Ann_Thomas

info.actors.3 Jonathan_G._Neff

$ wjson fielddata3

{

"year":2013,

"title":"Turn It Down, Or Else!",

"info":{

        "directors":[

                "Alice Smith",

                "Bob Jones"

                ],

        "release date":"2013-01-18T00:00:00Z",

        "rating":6.2,

        "genres":[

                "Comedy",

                "Drama"

                ],

        "image url":"http://ia.media-imdb.com/images/N/O9ERWAU7FS797AJ7LU8HN09AMUP908RLlo5JF90EWR7LJKQ7@@. V1 SX400 .jpg",

        "plot":"A rock band plays their music at high volumes, annoying the neighbors.",

        "rank":11,

        "running time secs":5215,

        "actors":[

                "David Matthewman",

                "Ann Thomas",

                "Jonathan G. Neff"

                ]

        }

}

Example 4

$ cat fielddata

data1 null

data2 _

data3 _

data4 true

data5 false

data6 0.000000000000000000000000000000000662607

$ wjson fielddata

{

  "data1" : "null",

  "data2" : "",

  "data3" : "",

  "data4" : "true",

  "data5" : "false",

  "data6" : 0.000000000000000000000000000000000662607

}

$ wjson --null --truefalse fielddata

{

  "data1" : "null",

  "data2" : null,

  "data3" : null,

  "data4" : true,

  "data5" : false,

  "data6" : 0.000000000000000000000000000000000662607

}

$ wjson -n null --null --truefalse fielddata

{

  "data1" : null,

  "data2" : "_",

  "data3" : "_",

  "data4" : true,

  "data5" : false,

  "data6" : 0.000000000000000000000000000000000662607

}