Try the
jc
web demo
JC is now available as an Ansible filter plugin in the
community.general
collection. See this blog post for an example.
JSON CLI output utility
jc
JSONifies the output of many CLI tools and file-types for easier parsing in scripts. See the Parsers section for supported commands and file-types.
dig example.com | jc --dig
[{"id":38052,"opcode":"QUERY","status":"NOERROR","flags":["qr","rd","ra"],"query_num":1,"answer_num":1,
"authority_num":0,"additional_num":1,"opt_pseudosection":{"edns":{"version":0,"flags":[],"udp":4096}},"question":
{"name":"example.com.","class":"IN","type":"A"},"answer":[{"name":"example.com.","class":"IN","type":"A","ttl":
39049,"data":"93.184.216.34"}],"query_time":49,"server":"2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)","when":
"Fri Apr 16 16:09:00 PDT 2021","rcvd":56,"when_epoch":1618614540,"when_epoch_utc":null}]
This allows further command-line processing of output with tools like jq
or jello
by piping commands:
$ dig example.com | jc --dig | jq -r '.[].answer[].data'
93.184.216.34
or using the alternative "magic" syntax:
$ jc dig example.com | jq -r '.[].answer[].data'
93.184.216.34
The jc
parsers can also be used as python modules. In this case the output will be a python dictionary, or list of dictionaries, instead of JSON:
>>> import subprocess
>>> import jc.parsers.dig
>>>
>>> cmd_output = subprocess.check_output(['dig', 'example.com'], text=True)
>>> data = jc.parsers.dig.parse(cmd_output)
>>>
>>> data
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', 'flags': ['qr', 'rd', 'ra'], 'query_num': 1, 'answer_num':
1, 'authority_num': 0, 'additional_num': 1, 'opt_pseudosection': {'edns': {'version': 0, 'flags': [], 'udp':
4096}}, 'question': {'name': 'example.com.', 'class': 'IN', 'type': 'A'}, 'answer': [{'name': 'example.com.',
'class': 'IN', 'type': 'A', 'ttl': 29658, 'data': '93.184.216.34'}], 'query_time': 52, 'server':
'2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)', 'when': 'Fri Apr 16 16:13:00 PDT 2021', 'rcvd': 56,
'when_epoch': 1618614780, 'when_epoch_utc': None}]
Two representations of the data are available. The default representation uses a strict schema per parser and converts known numbers to int/float JSON values. Certain known values of None
are converted to JSON null
, known boolean values are converted, and, in some cases, additional semantic context fields are added.
To access the raw, pre-processed JSON, use the -r
cli option or the raw=True
function parameter in parse()
.
Schemas for each parser can be found at the documentation link beside each Parser below.
Release notes can be found here.
For more information on the motivations for this project, please see my blog post on Bringing the Unix Philosophy to the 21st Century.
See also:
Use Cases:
There are several ways to get jc
. You can install via pip
, OS package repositories, via DEB/RPM/MSI packaged binaries for linux and Windows, or by downloading the correct binary for your architecture and running it anywhere on your filesystem.
pip3 install jc
OS | Command |
---|---|
Debian/Ubuntu linux | apt-get install jc |
Fedora linux | dnf install jc |
openSUSE linux | zypper install jc |
Arch linux | pacman -S jc |
NixOS linux | nix-env -iA nixpkgs.jc or nix-env -iA nixos.jc |
Guix System linux | guix install jc |
macOS | brew install jc |
FreeBSD | portsnap fetch update && cd /usr/ports/textproc/py-jc && make install clean |
Ansible filter plugin | ansible-galaxy collection install community.general |
For more packages and binaries, see the jc packaging site.
jc
accepts piped input from STDIN
and outputs a JSON representation of the previous command's output to STDOUT
.
COMMAND | jc PARSER [OPTIONS]
Alternatively, the "magic" syntax can be used by prepending jc
to the command to be converted. Options can be passed to jc
immediately before the command is given. (Note: command aliases and shell builtins are not supported)
jc [OPTIONS] COMMAND
The JSON output can be compact (default) or pretty formatted with the -p
option.
--acpi
enables the acpi
command parser (documentation)--airport
enables the airport -I
command parser (documentation)--airport-s
enables the airport -s
command parser (documentation)--arp
enables the arp
command parser (documentation)--blkid
enables the blkid
command parser (documentation)--cksum
enables the cksum
and sum
command parser (documentation)--crontab
enables the crontab
command and file parser (documentation)--crontab-u
enables the crontab
file parser with user support (documentation)--csv
enables the CSV file parser (documentation)--date
enables the date
command parser (documentation)--df
enables the df
command parser (documentation)--dig
enables the dig
command parser (documentation)--dir
enables the dir
command parser (documentation)--dmidecode
enables the dmidecode
command parser (documentation)--dpkg-l
enables the dpkg -l
command parser (documentation)--du
enables the du
command parser (documentation)--env
enables the env
command parser (documentation)--file
enables the file
command parser (documentation)--finger
enables the finger
command parser (documentation)--free
enables the free
command parser (documentation)--fstab
enables the /etc/fstab
file parser (documentation)--group
enables the /etc/group
file parser (documentation)--gshadow
enables the /etc/gshadow
file parser (documentation)--hash
enables the hash
command parser (documentation)--hashsum
enables the hashsum command parser (md5sum
, shasum
, etc.) (documentation)--hciconfig
enables the hciconfig
command parser (documentation)--history
enables the history
command parser (documentation)--hosts
enables the /etc/hosts
file parser (documentation)--id
enables the id
command parser (documentation)--ifconfig
enables the ifconfig
command parser (documentation)--ini
enables the INI file parser (documentation)--iptables
enables the iptables
command parser (documentation)--iw-scan
enables the iw dev [device] scan
command parser (documentation)--jobs
enables the jobs
command parser (documentation)--kv
enables the Key/Value file parser (documentation)--last
enables the last
and lastb
command parser (documentation)--ls
enables the ls
command parser (documentation)--ls-s
enables the ls
command streaming parser (documentation)--lsblk
enables the lsblk
command parser (documentation)--lsmod
enables the lsmod
command parser (documentation)--lsof
enables the lsof
command parser (documentation)--mount
enables the mount
command parser (documentation)--netstat
enables the netstat
command parser (documentation)--ntpq
enables the ntpq -p
command parser (documentation)--passwd
enables the /etc/passwd
file parser (documentation)--ping
enables the ping
and ping6
command parser (documentation)--ping-s
enables the ping
and ping6
command streaming parser (documentation)--pip-list
enables the pip list
command parser (documentation)--pip-show
enables the pip show
command parser (documentation)--ps
enables the ps
command parser (documentation)--route
enables the route
command parser (documentation)--rpm-qi
enables the rpm -qi
command parser (documentation)--sfdisk
enables the sfdisk
command parser (documentation)--shadow
enables the /etc/shadow
file parser (documentation)--ss
enables the ss
command parser (documentation)--stat
enables the stat
command parser (documentation)--sysctl
enables the sysctl
command parser (documentation)--systemctl
enables the systemctl
command parser (documentation)--systemctl-lj
enables the systemctl list-jobs
command parser (documentation)--systemctl-ls
enables the systemctl list-sockets
command parser (documentation)--systemctl-luf
enables the systemctl list-unit-files
command parser (documentation)--systeminfo
enables the systeminfo
command parser (documentation)--time
enables the /usr/bin/time
command parser (documentation)--timedatectl
enables the timedatectl status
command parser (documentation)--tracepath
enables the tracepath
and tracepath6
command parser (documentation)--traceroute
enables the traceroute
and traceroute6
command parser (documentation)--ufw
enables the ufw status
command parser (documentation)--ufw-appinfo
enables the ufw app info [application]
command parser (documentation)--uname
enables the uname -a
command parser (documentation)--upower
enables the upower
command parser (documentation)--uptime
enables the uptime
command parser (documentation)--vmstat
enables the vmstat
command parser (documentation)--vmstat-s
enables the vmstat
command streaming parser (documentation)--w
enables the w
command parser (documentation)--wc
enables the wc
command parser (documentation)--who
enables the who
command parser (documentation)--xml
enables the XML file parser (documentation)--yaml
enables the YAML file parser (documentation)-a
about jc
. Prints information about jc
and the parsers (in JSON, of course!)-d
debug mode. Prints trace messages if parsing issues are encountered (use -dd
for verbose debugging)-h
help. Use jc -h --parser_name
for parser documentation-m
monochrome JSON output-p
pretty format the JSON output-q
quiet mode. Suppresses parser warning messages (use -qq
to ignore streaming parser errors)-r
raw output. Provides a more literal JSON output, typically with string values and no additional semantic processing-u
unbuffer output-v
version informationAny fatal errors within jc
will generate an exit code of 100
, otherwise the exit code will be 0
. When using the "magic" syntax (e.g. jc ifconfig eth0
), jc
will store the exit code of the program being parsed and add it to the jc
exit code. This way it is easier to determine if an error was from the parsed program or jc
.
Consider the following examples using ifconfig
:
ifconfig exit code |
jc exit code |
Combined exit code | Interpretation |
---|---|---|---|
0 |
0 |
0 |
No errors |
1 |
0 |
1 |
Error in ifconfig |
0 |
100 |
100 |
Error in jc |
1 |
100 |
101 |
Error in both ifconfig and jc |
You can specify custom colors via the JC_COLORS
environment variable. The JC_COLORS
environment variable takes four comma separated string values in the following format:
JC_COLORS=<keyname_color>,<keyword_color>,<number_color>,<string_color>
Where colors are: black
, red
, green
, yellow
, blue
, magenta
, cyan
, gray
, brightblack
, brightred
, brightgreen
, brightyellow
, brightblue
, brightmagenta
, brightcyan
, white
, or default
For example, to set to the default colors:
JC_COLORS=blue,brightblack,magenta,green
or
JC_COLORS=default,default,default,default
Most parsers load all of the data from STDIN, parse it, then output the entire JSON document serially. There are some streaming parsers (e.g. ls-s
and ping-s
) that immediately start processing and outputing the data line-by-line as JSON Lines (aka NDJSON) while it is being received from STDIN. This can significantly reduce the amount of memory required to parse large amounts of command output (e.g. ls -lR /
) and can sometimes process the data more quickly. Streaming parsers have slightly different behavior than standard parsers as outlined below.
Note: Streaming parsers cannot be used with the "magic" syntax
You may want to ignore parsing errors when using streaming parsers since these may be used in long-lived processing pipelines and errors can break the pipe. To ignore parsing errors, use the -qq
cli option or the ignore_exceptions=True
argument with the parse()
function. This will add a _jc_meta
object to the JSON output with a success
attribute. If success
is true
, then there were no issues parsing the line. If success
is false
, then a parsing issue was found and error
and line
fields will be added to include a short error description and the contents of the unparsable line, respectively:
Successfully parsed line with -qq
option:
{
"command_data": "data",
"_jc_meta": {
"success": true
}
}
Unsuccessfully parsed line with -qq
option:
{
"_jc_meta": {
"success": false,
"error": "error message",
"line": "original line data"
}
}
Most operating systems will buffer output that is being piped from process to process. The buffer is usually around 4KB. When viewing the output in the terminal the OS buffer is not engaged so output is immediately displayed on the screen. When piping multiple processes together, though, it may seem as if the output is hanging when the input data is very slow (e.g. ping
):
$ ping 1.1.1.1 | jc --ping-s | jq
<slow output>
This is because the OS engages the 4KB buffer between jc
and jq
in this example. To display the data on the terminal in realtime, you can disable the buffer with the -u
(unbuffer) cli option:
$ ping 1.1.1.1 | jc --ping-s -u | jq
{"type":"reply","pattern":null,"timestamp":null,"bytes":"64","response_ip":"1.1.1.1","icmp_seq":"1","ttl":"128","time_ms":"24.6","duplicate":false}
{"type":"reply","pattern":null,"timestamp":null,"bytes":"64","response_ip":"1.1.1.1","icmp_seq":"2","ttl":"128","time_ms":"26.8","duplicate":false}
...
Note: Unbuffered output can be slower for large data streams.
Streaming parsers accept any iterable object and return a generator iterator object allowing lazy processing of the data. The input data should iterate on lines of string data. Examples of good input data are sys.stdin
or str.splitlines()
.
To use the generator object in your code, simply loop through it or use the next() builtin function:
import jc.parsers.ls_s
result = jc.parsers.ls_s.parse(ls_command_output.splitlines())
for item in result:
print(item["filename"])
Custom local parser plugins may be placed in a jc/jcparsers
folder in your local "App data directory":
$HOME/.local/share/jc/jcparsers
$HOME/Library/Application Support/jc/jcparsers
$LOCALAPPDATA\jc\jc\jcparsers
Local parser plugins are standard python module files. Use the jc/parsers/foo.py
parser as a template and simply place a .py
file in the jcparsers
subfolder.
Local plugin filenames must be valid python module names, therefore must consist entirely of alphanumerics and start with a letter. Local plugins may override default parsers.
Note: The application data directory follows the XDG Base Directory Specification
For best results set the LANG
locale environment variable to C
or en_US.UTF-8
. For example, either by setting directly on the command-line:
$ LANG=C date | jc --date
or by exporting to the environment before running commands:
$ export LANG=C
Some parsers have calculated epoch timestamp fields added to the output. Unless a timestamp field name has a _utc
suffix it is considered naive. (i.e. based on the local timezone of the system the jc
parser was run on).
If a UTC timezone can be detected in the text of the command output, the timestamp will be timezone aware and have a _utc
suffix on the key name. (e.g. epoch_utc
) No other timezones are supported for aware timestamps.
Some parsers like dig
, xml
, csv
, etc. will work on any platform. Other parsers that convert platform-specific output will generate a warning message if they are run on an unsupported platform. To see all parser information, including compatibility, run jc -ap
.
You may still use a parser on an unsupported platform - for example, you may want to parse a file with linux lsof
output on an macOS or Windows laptop. In that case you can suppress the warning message with the -q
cli option or the quiet=True
function parameter in parse()
:
macOS:
cat lsof.out | jc --lsof -q
or Windows:
type lsof.out | jc --lsof -q
Tested on:
Feel free to add/improve code or parsers! You can use the jc/parsers/foo.py
or jc/parsers/foo_s.py (streaming)
parsers as a template and submit your parser with a pull request.
Please see the Contributing Guidelines for more information.
ifconfig-parser
module by KnightWhoSayNixmltodict
module by Martín Blechruamel.yaml
module by Anthon van der Neuttrparse
module by Luis BenitezHere are some examples of jc
output. For more examples, see here or the parser documentation.
arp | jc --arp -p # or: jc -p arp
[
{
"address": "gateway",
"hwtype": "ether",
"hwaddress": "00:50:56:f7:4a:fc",
"flags_mask": "C",
"iface": "ens33"
},
{
"address": "192.168.71.1",
"hwtype": "ether",
"hwaddress": "00:50:56:c0:00:08",
"flags_mask": "C",
"iface": "ens33"
},
{
"address": "192.168.71.254",
"hwtype": "ether",
"hwaddress": "00:50:56:fe:7a:b4",
"flags_mask": "C",
"iface": "ens33"
}
]
cat homes.csv
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres", "Taxes"
142, 160, 28, 10, 5, 3, 60, 0.28, 3167
175, 180, 18, 8, 4, 1, 12, 0.43, 4033
129, 132, 13, 6, 3, 1, 41, 0.33, 1471
...
cat homes.csv | jc --csv -p
[
{
"Sell": "142",
"List": "160",
"Living": "28",
"Rooms": "10",
"Beds": "5",
"Baths": "3",
"Age": "60",
"Acres": "0.28",
"Taxes": "3167"
},
{
"Sell": "175",
"List": "180",
"Living": "18",
"Rooms": "8",
"Beds": "4",
"Baths": "1",
"Age": "12",
"Acres": "0.43",
"Taxes": "4033"
},
{
"Sell": "129",
"List": "132",
"Living": "13",
"Rooms": "6",
"Beds": "3",
"Baths": "1",
"Age": "41",
"Acres": "0.33",
"Taxes": "1471"
}
]
cat /etc/hosts | jc --hosts -p
[
{
"ip": "127.0.0.1",
"hostname": [
"localhost"
]
},
{
"ip": "::1",
"hostname": [
"ip6-localhost",
"ip6-loopback"
]
},
{
"ip": "fe00::0",
"hostname": [
"ip6-localnet"
]
}
]
ifconfig | jc --ifconfig -p # or: jc -p ifconfig
[
{
"name": "ens33",
"flags": 4163,
"state": [
"UP",
"BROADCAST",
"RUNNING",
"MULTICAST"
],
"mtu": 1500,
"ipv4_addr": "192.168.71.137",
"ipv4_mask": "255.255.255.0",
"ipv4_bcast": "192.168.71.255",
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
"ipv6_mask": 64,
"ipv6_scope": "0x20",
"mac_addr": "00:0c:29:3b:58:0e",
"type": "Ethernet",
"rx_packets": 8061,
"rx_bytes": 1514413,
"rx_errors": 0,
"rx_dropped": 0,
"rx_overruns": 0,
"rx_frame": 0,
"tx_packets": 4502,
"tx_bytes": 866622,
"tx_errors": 0,
"tx_dropped": 0,
"tx_overruns": 0,
"tx_carrier": 0,
"tx_collisions": 0,
"metric": null
}
]
cat example.ini
[DEFAULT]
ServerAliveInterval = 45
Compression = yes
CompressionLevel = 9
ForwardX11 = yes
[bitbucket.org]
User = hg
[topsecret.server.com]
Port = 50022
ForwardX11 = no
cat example.ini | jc --ini -p
{
"bitbucket.org": {
"serveraliveinterval": "45",
"compression": "yes",
"compressionlevel": "9",
"forwardx11": "yes",
"user": "hg"
},
"topsecret.server.com": {
"serveraliveinterval": "45",
"compression": "yes",
"compressionlevel": "9",
"forwardx11": "no",
"port": "50022"
}
}
$ ls -l /usr/bin | jc --ls -p # or: jc -p ls -l /usr/bin
[
{
"filename": "apropos",
"link_to": "whatis",
"flags": "lrwxrwxrwx.",
"links": 1,
"owner": "root",
"group": "root",
"size": 6,
"date": "Aug 15 10:53"
},
{
"filename": "ar",
"flags": "-rwxr-xr-x.",
"links": 1,
"owner": "root",
"group": "root",
"size": 62744,
"date": "Aug 8 16:14"
},
{
"filename": "arch",
"flags": "-rwxr-xr-x.",
"links": 1,
"owner": "root",
"group": "root",
"size": 33080,
"date": "Aug 19 23:25"
}
]
netstat -apee | jc --netstat -p # or: jc -p netstat -apee
[
{
"proto": "tcp",
"recv_q": 0,
"send_q": 0,
"local_address": "localhost",
"foreign_address": "0.0.0.0",
"state": "LISTEN",
"user": "systemd-resolve",
"inode": 26958,
"program_name": "systemd-resolve",
"kind": "network",
"pid": 887,
"local_port": "domain",
"foreign_port": "*",
"transport_protocol": "tcp",
"network_protocol": "ipv4"
},
{
"proto": "tcp6",
"recv_q": 0,
"send_q": 0,
"local_address": "[::]",
"foreign_address": "[::]",
"state": "LISTEN",
"user": "root",
"inode": 30510,
"program_name": "sshd",
"kind": "network",
"pid": 1186,
"local_port": "ssh",
"foreign_port": "*",
"transport_protocol": "tcp",
"network_protocol": "ipv6"
},
{
"proto": "udp",
"recv_q": 0,
"send_q": 0,
"local_address": "localhost",
"foreign_address": "0.0.0.0",
"state": null,
"user": "systemd-resolve",
"inode": 26957,
"program_name": "systemd-resolve",
"kind": "network",
"pid": 887,
"local_port": "domain",
"foreign_port": "*",
"transport_protocol": "udp",
"network_protocol": "ipv4"
},
{
"proto": "raw6",
"recv_q": 0,
"send_q": 0,
"local_address": "[::]",
"foreign_address": "[::]",
"state": "7",
"user": "systemd-network",
"inode": 27001,
"program_name": "systemd-network",
"kind": "network",
"pid": 867,
"local_port": "ipv6-icmp",
"foreign_port": "*",
"transport_protocol": null,
"network_protocol": "ipv6"
},
{
"proto": "unix",
"refcnt": 2,
"flags": null,
"type": "DGRAM",
"state": null,
"inode": 33322,
"program_name": "systemd",
"path": "/run/user/1000/systemd/notify",
"kind": "socket",
"pid": 1607
}
]
cat /etc/passwd | jc --passwd -p
[
{
"username": "root",
"password": "*",
"uid": 0,
"gid": 0,
"comment": "System Administrator",
"home": "/var/root",
"shell": "/bin/sh"
},
{
"username": "daemon",
"password": "*",
"uid": 1,
"gid": 1,
"comment": "System Services",
"home": "/var/root",
"shell": "/usr/bin/false"
}
]
ping 8.8.8.8 -c 3 | jc --ping -p # or: jc -p ping 8.8.8.8 -c 3
{
"destination_ip": "8.8.8.8",
"data_bytes": 56,
"pattern": null,
"destination": "8.8.8.8",
"packets_transmitted": 3,
"packets_received": 3,
"packet_loss_percent": 0.0,
"duplicates": 0,
"time_ms": 2005.0,
"round_trip_ms_min": 23.835,
"round_trip_ms_avg": 30.46,
"round_trip_ms_max": 34.838,
"round_trip_ms_stddev": 4.766,
"responses": [
{
"type": "reply",
"timestamp": null,
"bytes": 64,
"response_ip": "8.8.8.8",
"icmp_seq": 1,
"ttl": 118,
"time_ms": 23.8,
"duplicate": false
},
{
"type": "reply",
"timestamp": null,
"bytes": 64,
"response_ip": "8.8.8.8",
"icmp_seq": 2,
"ttl": 118,
"time_ms": 34.8,
"duplicate": false
},
{
"type": "reply",
"timestamp": null,
"bytes": 64,
"response_ip": "8.8.8.8",
"icmp_seq": 3,
"ttl": 118,
"time_ms": 32.7,
"duplicate": false
}
]
}
ps axu | jc --ps -p # or: jc -p ps axu
[
{
"user": "root",
"pid": 1,
"cpu_percent": 0.0,
"mem_percent": 0.1,
"vsz": 128072,
"rss": 6784,
"tty": null,
"stat": "Ss",
"start": "Nov09",
"time": "0:08",
"command": "/usr/lib/systemd/systemd --switched-root --system --deserialize 22"
},
{
"user": "root",
"pid": 2,
"cpu_percent": 0.0,
"mem_percent": 0.0,
"vsz": 0,
"rss": 0,
"tty": null,
"stat": "S",
"start": "Nov09",
"time": "0:00",
"command": "[kthreadd]"
},
{
"user": "root",
"pid": 4,
"cpu_percent": 0.0,
"mem_percent": 0.0,
"vsz": 0,
"rss": 0,
"tty": null,
"stat": "S<",
"start": "Nov09",
"time": "0:00",
"command": "[kworker/0:0H]"
}
]
traceroute -m 2 8.8.8.8 | jc --traceroute -p # or: jc -p traceroute -m 2 8.8.8.8
{
"destination_ip": "8.8.8.8",
"destination_name": "8.8.8.8",
"hops": [
{
"hop": 1,
"probes": [
{
"annotation": null,
"asn": null,
"ip": "192.168.1.254",
"name": "dsldevice.local.net",
"rtt": 6.616
},
{
"annotation": null,
"asn": null,
"ip": "192.168.1.254",
"name": "dsldevice.local.net",
"rtt": 6.413
},
{
"annotation": null,
"asn": null,
"ip": "192.168.1.254",
"name": "dsldevice.local.net",
"rtt": 6.308
}
]
},
{
"hop": 2,
"probes": [
{
"annotation": null,
"asn": null,
"ip": "76.220.24.1",
"name": "76-220-24-1.lightspeed.sntcca.sbcglobal.net",
"rtt": 29.367
},
{
"annotation": null,
"asn": null,
"ip": "76.220.24.1",
"name": "76-220-24-1.lightspeed.sntcca.sbcglobal.net",
"rtt": 40.197
},
{
"annotation": null,
"asn": null,
"ip": "76.220.24.1",
"name": "76-220-24-1.lightspeed.sntcca.sbcglobal.net",
"rtt": 29.162
}
]
}
]
}
uptime | jc --uptime -p # or: jc -p uptime
{
"time": "11:35",
"uptime": "3 days, 4:03",
"users": 5,
"load_1m": 1.88,
"load_5m": 2.0,
"load_15m": 1.94,
"time_hour": 11,
"time_minute": 35,
"time_second": null,
"uptime_days": 3,
"uptime_hours": 4,
"uptime_minutes": 3,
"uptime_total_seconds": 273780
}
cat cd_catalog.xml
<?xml version="1.0" encoding="UTF-8"?>
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</CD>
...
cat cd_catalog.xml | jc --xml -p
{
"CATALOG": {
"CD": [
{
"TITLE": "Empire Burlesque",
"ARTIST": "Bob Dylan",
"COUNTRY": "USA",
"COMPANY": "Columbia",
"PRICE": "10.90",
"YEAR": "1985"
},
{
"TITLE": "Hide your heart",
"ARTIST": "Bonnie Tyler",
"COUNTRY": "UK",
"COMPANY": "CBS Records",
"PRICE": "9.90",
"YEAR": "1988"
}
]
}
}
cat istio.yaml
apiVersion: "authentication.istio.io/v1alpha1"
kind: "Policy"
metadata:
name: "default"
namespace: "default"
spec:
peers:
- mtls: {}
---
apiVersion: "networking.istio.io/v1alpha3"
kind: "DestinationRule"
metadata:
name: "default"
namespace: "default"
spec:
host: "*.default.svc.cluster.local"
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
cat istio.yaml | jc --yaml -p
[
{
"apiVersion": "authentication.istio.io/v1alpha1",
"kind": "Policy",
"metadata": {
"name": "default",
"namespace": "default"
},
"spec": {
"peers": [
{
"mtls": {}
}
]
}
},
{
"apiVersion": "networking.istio.io/v1alpha3",
"kind": "DestinationRule",
"metadata": {
"name": "default",
"namespace": "default"
},
"spec": {
"host": "*.default.svc.cluster.local",
"trafficPolicy": {
"tls": {
"mode": "ISTIO_MUTUAL"
}
}
}
}
]
© 2019-2021 Kelly Brazil
高速公路导航提示中IC、JC、SA等字样的含义 经常在导航过程中见到IC、JC、SA等字样,很多人都不知道它们的含义是什么。下面我们就逐一的做出解释。 IC : Inter Change 英文缩写,意为高速公路转换出入口,即高速公路至一般公路的出入匝道。从标有“IC”的地方,可以下高速公路。 JC : Joint Change/Circuit 的英文缩写,意为高速公路连接口或连接匝道。即不同高速公
摘 要: 在水工结构可靠度分析中,随机变量的分布形式常因几何尺寸、物理环境等条件限制,传统JC法已经不适用,因此需要对部分变量进行截尾分布处理。在此借助MATLAB丰富的函数资源,编制出截尾分布处理后的改进JC法求解程序。算例研究表明该方法的可行性,以及程序的简易、实用性。 关键词: 可靠度; 截尾分布; JC法; MATLAB 中图分类号: TV314 文献标识码: A 文章编号: 1009-8
问题内容: 建立 Java不为JCE无限强度策略文件提供现成的支持 这样可以防止用户使用AES-256,这是广泛使用的加密标准中最大的密钥大小 不包括策略文件会导致许多问题: 意外的异常 不满意的解决方法 只需安装它们 使用不同的实现 使用可能违反Java许可协议的反射 JRE更新后损坏 安装后混乱 所有这些噪音导致程序损坏和/或错误 题 为什么不提供这些服务,将其视为败类? 问题答案: 事实证明
问题内容: 目的:JComboBox列出用户可以选择的年龄 我意识到我需要一个整数数组。Java中Math函数的哪一部分可以让我轻松地做到这一点?数字列表将按顺序从1-100开始。 问题答案: 我不太明白为什么需要数学函数。 这将工作:
问题内容: 对于以下任务,我需要您的建议和指导。 我有一个包含两个JComboBox的框架,假设它们分别命名为combo1和combo2,一个JTable和其他组件。 在初始阶段,当上述组件可见框架时。combo1组合框填充了一些值,但在初始阶段未选择任何值,combo2组合框被禁用并且表为空。 我在combo1和combo2上添加了一个actionListener。combo1中有两种类型的值,
问题内容: 我已经为我的应用程序制作了GUI。JFrame有2个JPanel,panel1和panel2。panel1就是这样,带有自定义绘画的JPanel每5毫秒重新绘制一次。 panel2是我第一次尝试CardLayout实现:它包含JPanels subPanel1和subPanel2。subPanel1包含一个JComboBox并添加到panel2:中。 subPanel2有命令,我在其中
问题内容: 我正在使用a 从sql数据库搜索查询。这是我的代码。 = JComboBox 但是,当我在组合框中键入一个字母时,它将添加数据库中的所有项目。我知道总是给出一个空字符串。而且,只要我键入一个字母,组合框的文本字段就会为空(我不能键入两个字母的单词)。如何解决这个问题?谢谢。 问题答案: 问题的原因如下: 始终为空是因为您在打电话之前先打电话。这意味着,在获得所选内容之前,将清除(与所选
问题内容: 人们为什么使用Bouncycastle而不是Java Cryptography Extension?有什么区别? 问题答案: 与 Sun提供的默认JCE相比,BouncyCastle具有更多的密码套件和算法。 除此之外,BouncyCastle还有许多实用程序可读取诸如PEM和ASN.1之类的奥秘格式,没有理智的人会想要重写自己。
问题内容: 我目前用于监视Java应用程序的性能指标,并希望 编写 此 数据采集 脚本 。 有没有办法将这些VM指标(堆内存使用率,线程数,CPU使用率等)检索到? 输入的数据并没有完全减少。 谢谢 问题答案: jconsole只是提供了平台MBeanServer中的JMX MBean的包装。 您可以编写一个程序,使用附加API连接到您的VM ,然后再查询MBean。 或者,您可以通过RMI公开平
问题内容: 为基于JVM的服务确定docker容器的尺寸非常棘手(众所周知)。我很确定我们的容器尺寸略有不足,并且想清除一些与监视时看到的特定jcmd(本机内存跟踪器)输出有关的问题。 问题: jcmd报告的“内部”中是否包含直接字节缓冲区? jcmd报告的“代码”中除代码缓存外还有什么? 是否有一种很好的方法来限制jcmd报告的“代码”部分。我阅读了https://docs.oracle.com