Skip to content

wstein/bin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

433 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My shell scripts

Should be compatible with POSIX shell.

j2ad

j2ad converts JSON to AION delimited syntax. It reads JSON from a file or standard input and writes compact output by default:

cat input.json | j2ad
j2ad --pretty --width 80 input.json output.aion

Strings that are valid AION atoms are emitted bare. Strings that need quoting escape JSON-sensitive characters, including quotes, backslashes, newlines, tabs, backspace, formfeed, and other control characters.

Supported CLI options:

  • --pretty / --no-pretty toggles expanded output.

  • --width N or --width=N sets the target pretty-print width. The minimum is 40.

  • --object-threshold N or --object-threshold=N expands objects with at least N fields even when the compact form fits. Set 0 to disable that heuristic.

  • --expand-lists / --no-expand-lists toggles expansion of lists containing non-scalar values.

Configuration is read from ~/.j2adrc and then .j2adrc; CLI options override both files. Config files accept whole-line and inline # comments:

pretty true
width 80 # keep output readable in terminals
object_threshold 3
expand_lists true

j2ai

j2ai converts JSON to AION indented syntax. It reads JSON from a file or standard input and writes scalar-only lists on one line when they fit:

cat input.json | j2ai
j2ai --width 80 --no-single-line-lists input.json output.aion

Supported CLI options:

  • --width N or --width=N sets the target width for single-line lists. The minimum is 40.

  • --single-line-lists / --no-single-line-lists toggles compact rendering for scalar-only lists.

Configuration is read from ~/.j2airc and then .j2airc; CLI options override both files. Config files accept whole-line and inline # comments:

width 80 # keep list fields readable in terminals
single_line_lists true

Lists containing objects or nested non-scalar values remain expanded so the indented structure stays clear.

j2as

j2as converts JSON Lines / JSONL to AION delimited stream syntax. It reads one JSON value per input line and writes one AION stream value per output line:

cat input.jsonl | j2as
j2as --no-contract input.jsonl output.aionl

Supported CLI options:

  • --contract emits contract urn:aion:delimited-stream as the first output line. This is the default.

  • --no-contract omits the contract header.

JSONL input must contain exactly one valid JSON value per non-empty line. Blank lines are rejected, including whitespace-only lines, while a single final newline is accepted. Object key order is preserved.

Example input:

"line1"
2
3
[1,2,3]
{"type":"test","desc":"this is test data"}
{"tag":"#release","kind":"record","literal":"true","num_as_text":"123"}

Default output:

contract urn:aion:delimited-stream
"line1"
2
3
[1 2 3]
{type test desc "this is test data"}
{tag #release kind record literal "true" num_as_text "123"}

Top-level JSON strings are emitted as quoted AION strings. Strings inside objects and arrays use the compact delimited rendering rules: ordinary strings may be bare, while reserved literals, number-like strings, strings with whitespace, and control-character strings are quoted and escaped.

Development

Format the Elixir scripts and tests before committing:

mix format
mix format --check-formatted

Run the converter test suites directly:

elixir test/j2ad_test.exs
elixir test/j2ai_test.exs
elixir test/j2as_test.exs

About

Every day linux tools

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors