Package com.benesult.vivjson
Class CommandLine
java.lang.Object
com.benesult.vivjson.CommandLine
Command-line client of VivJson.
Usage: java -jar vivjson.jar [ [option] <code or file> ... ]
option: - "+" is concatenated the previous code and the following
code, such as
"a=" + "[1, 2]" "return(a[0]+a[1])"
- "-i" or "--stdin" reads from PIPE.
For example, the following command shows "6".
echo '{"a":3}' | java -jar vivjson.jar -i "return(a*2)"
"-i=<name>" or "--stdin=<name>" gives variable name for
value that read from PIPE.
For example, the following command shows
{"dog": 2, "cat": 3}.
echo '[{"x":"dog","y":2},{"x":"cat","y":3}]' | \
java -jar vivjson.jar -i=data \
"z={},for(v in data){z[v.x]=v.y},print(z)"
- "-j" or "--json" indicates that the following code is JSON.
For example, error occurs because the following value is
invalid as JSON.
java -jar vivjson.jar -j '{"a":1+2}'
- "-v" or "--version" shows version.
Environment: Java 9 or later
Last modified: 2025-03-28
- Author:
- Fumiaki Motegi (motegi@benesult.com)
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
CommandLine
public CommandLine()
-
-
Method Details
-
run
Runs VivJson in command-line.- Parameters:
arguments
- arguments from command-lineoutputs
- stdout and stderr.
1st element is a string of stdout if success, null otherwise.
2nd element is null if success, a string of stderr otherwise.
-
main
Runs VivJson in command-line.- Parameters:
arguments
- arguments from command-line
-