Hitachi

JP1 Version 11 JP1/Advanced Shell Description, User's Guide, Reference, and Operator's Guide 


10.3.35 getJsonValue (gets a value corresponding to the name of JSON data)

Syntax

getJsonValue  [-e character-encoding]  name  [file-path-name]

Description

This command searches for element name from the XML file specified for argument and outputs values for all fully matched names.

Arguments

-e character-encoding
Windows edition

Specifies the character encoding for JSON file. "SJIS" or "UTF8" can be specified. If you do not specify this option, the character encoding is treated as UTF8.

UNIX edition

This command specifies the character encoding for JSON file in the format of value of the environment variable LANG. For values that can be specified, see 2.2.4 Encoding used in JP1/Advanced Shell.

If you do not specify this option, assume that the character encoding is specified in the format of the value of the LANG environment variable in the environment where JP1/Advanced Shell operates.

For example, if the JSON file with the character encoding UTF-8 in AIX is treated, specify "JA_JP" or "JA_JP.UTF-8" for -e option.

name

This command specifies the name to be searched.

file-path-name

This command specifies the path of JSON file. If you do not specify the file path name, input from the standard input.

Output to the standard output

Value that corresponds to JSON data.

Return codes

Return code

Meaning

0

Normal termination

Not less than 1

Termination with an error

Notes

Examples

JSON data (data.json)
{ "city": [
    { "name":"Yokohama", "id":"0001", "value":{ "A":200, "B":100 } },
    { "name":"Kawasaki", "id":"0002", "value":{ "A":100, "B":300 } }
  ]
}

getJsonValue name data.json
# The following contents are output:
"Yokohama"
"Kawasaki"

getJsonValue -e SJIS value data.json
# The following contents are output:
{ "A":200, "B":100 }
{ "A":100, "B":300 }