jarg
- shorthand data serialization/encoding
jarg
[-h
] [-j
| -y
| -f
] [-V
] name=value [name=value ...]
jarg provides a shorthand syntax for writing encoded data formats. It works by adding name-value pairs to the current context, which starts out empty by default. It writes the final representation to standard output.
Each argument must be in the format of name=value. Each name must be in the HTML JSON form (http://www.w3.org/TR/html-json-forms/) format. The =value portion is optional, omitting it will cause the value to take the empty value of the current dialect. Literal values may be provided in the name:=value format and they will be interpreted according to the current dialect.
Each name-value pair is added to the current context. A starting context can be specified through standard input when not in a TTY, and must be in the same dialect as the output.
Output is determined by the current dialect. The default dialect is JSON.
The output will be a JSON object. Integers and floats are automatically recognized. The empty value is null.
The output will be a YAML document. Integers and floats are automatically recognized. The empty value is null.
The output will be a percent-encoded list of name/value pairs, in the application/x-www-form-urlencoded format. The empty value is an empty string.
-j
, --json
Set the current dialect to JSON. This is the default.
-y
, --yaml
Set the current dialect to YAML.
-f
, --form
Set the current dialect to form encoding.
-h
, --help
Show a help message and exit.
-V
, --version
Show the version and exit.
Error parsing literal value.
Write some JSON to standard output:
$ jarg foo=bar baz=123 bux:=true
{"foo": "bar", "baz": 123, "bux": true}
Repeating key names implicitly builds an array:
$ jarg a=1 a=2 a=3
{"a": [1, 2, 3]}
Missing array indexes are automatically filled in:
$ jarg a[2]=foo a[4]=bar
{"a": [null, null, "foo", null, "bar"]}
Creating nested objects is allowed too:
$ jarg foo[bar][baz]=quux
{"foo": {"bar": {"baz": "quux"}}}
Force a string representation of a number in JSON:
$ jarg foo:=\"123\"
{"foo": "123"}
Say something nice about jarg in form encoding:
$ jarg -f jarg="is cool and good"
jarg=is+cool+and+good
Development progress and issues are tracked on the project page.
https://github.com/jdp/jarg/issues
Copyright © 2014 Justin Poliey http://justinpoliey.com