1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2026-04-26 21:04:16 +02:00
Files
jc/docs/parsers/ping_s.md
T
2021-09-17 10:34:05 -07:00

1.8 KiB

Home

jc.parsers.ping_s

jc - JSON CLI output utility ping command output streaming parser

Usage (cli):

$ ping | jc --ping_s

Usage (module):

import jc.parsers.ping_s
result = jc.parsers.ping_s.parse(ping_command_output)    # result is an iterable object
for item in result:
    # do something

Note: When piping jc output to other processes it may appear the output is hanging due to the OS pipe buffers. This is because ping output is too small to quickly fill up the buffer. Use the -u option to unbuffer the jc output if you would like immediate output. See the readme for more information.

Schema:

{
  "ping":            string,
  "_meta":                       # This object only exists if using -q or quiet=True
    {
      "success":    booean,      # true if successfully parsed, false if error
      "error":      string,      # exists if "success" is false
      "line":       string       # exists if "success" is false
    }
}

Examples:

$ ping | jc --ping-s
{example output}
...

$ ping | jc --ping-s -r
{example output}
...

info

info()

Provides parser metadata (version, author, etc.)

parse

parse(data, raw=False, quiet=False)

Main text parsing generator function. Produces an iterable object.

Parameters:

data:        (string)  line-based text data to parse
raw:         (boolean) output preprocessed JSON if True
quiet:       (boolean) suppress warning messages and ignore parsing errors if True

Yields:

Dictionary. Raw or processed structured data.

Parser Information

Compatibility: linux, darwin, cygwin, aix, freebsd

Version 0.5 by Kelly Brazil (kellyjonbrazil@gmail.com)