Skip to content

Commit

Permalink
Add json parser
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Gladkov <[email protected]>
  • Loading branch information
legionus committed Nov 12, 2021
1 parent 40de628 commit 0927cfa
Show file tree
Hide file tree
Showing 48 changed files with 1,607 additions and 0 deletions.
40 changes: 40 additions & 0 deletions docs/shell-json.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
shell-json(3)

# NAME

json_foreach - function for streaming json parsing

# SYNOPSIS

- json_foreach
- json_foreach_handler type value
- json_get_last_name retvar
- json_get_full_name retvar [separator]

# DESCRIPTION

## json_foreach
The function consumes standard input to parse JSON and calls `json_foreach_handler` for each
simple value (`string`, `number`, `boolean` and `null`).

## json_foreach_handler
The function is a callback that is called for each JSON value. The function
receives the value type and the JSON value of the variable as arguments. Inside
the callback, you can get the field name by calling the `json_get_last_name`
or `json_get_full_name`.

## json_get_last_name
This is a helper that is meant to be called from the `json_foreach_handler`. It
puts into the `retvar` with the name of JSON field.

## json_get_full_name
Same as `json_get_last_name` but returns full JSON field name. The name is made
up of the parent names of the fields joined with a `separator`.

# AUTHOR
Authors and contributors of the programs included in the *libshell* package are listed
in the COPYING file.

# BUGS
Report bugs to the authors.

Loading

0 comments on commit 0927cfa

Please sign in to comment.