to nuon

For formats.

Converts table data into Nuon (Nushell Object Notation) text.

Command Type

built-in

Signature

> to nuon {flags}

Flags

  • --raw, -r: Remove all of the whitespace (overwrites -i, -t, and -p).
  • --indent, -i {number}: Specify indentation width.
  • --tabs, -t {number}: Specify indentation tab quantity.
  • --serialize, -s: Serialize nushell types that cannot be deserialized.
  • --raw-strings, -R: Use raw string syntax (r#’…’#) for strings with quotes or backslashes.
  • --list-of-records, -l: Serialize table values as list-of-records instead of table syntax.
  • --no-commas, -c: Do not use commas between items in tables and lists.
  • --pretty, -p: Format output with indentation and aligned table columns.

Input/output types:

input output
any string

Examples

Outputs a NUON string representing the contents of this list, compact by default.

> [1 2 3] | to nuon
[1, 2, 3]

Outputs a NUON array of ints, with pretty indentation.

> [1 2 3] | to nuon --indent 2
[
  1,
  2,
  3
]

Overwrite any set option with —raw.

> [1 2 3] | to nuon --indent 2 --raw
[1,2,3]

A more complex record with multiple data types.

> {date: 2000-01-01, data: [1 [2 3] 4.56]} | to nuon --indent 2
{
  date: 2000-01-01T00:00:00+00:00,
  data: [
    1,
    [
      2,
      3
    ],
    4.56
  ]
}

A more complex record with —raw.

> {date: 2000-01-01, data: [1 [2 3] 4.56]} | to nuon --raw
{date:2000-01-01T00:00:00+00:00,data:[1,[2,3],4.56]}

Use raw string syntax for strings with quotes or backslashes.

> 'hello "world"' | to nuon --raw-strings
r#'hello "world"'#

Serialize table values as a list of records instead of table syntax.

> [[a, b]; [1, 2], [3, 4]] | to nuon --list-of-records
[{a: 1, b: 2}, {a: 3, b: 4}]

Serialize table values as list of records with pretty indentation.

> [[a, b]; [1, 2], [3, 4]] | to nuon --list-of-records --indent 2
[
  {a: 1, b: 2},
  {a: 3, b: 4}
]

Output a list without commas between items.

> [1 2 3] | to nuon --no-commas
[1 2 3]

Output a record without commas between fields.

> {a: 1, b: 2} | to nuon --no-commas
{a: 1 b: 2}

Format output with pretty indentation and aligned table columns.

> [[name, age]; [Alice, 30], [Bob, 25]] | to nuon --pretty
[
  [name,  age];
  [Alice, 30],
  [Bob,   25]
]

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.