Home Explore Blog CI



nushell

commands/docs/from_json.md
69e07f7f484b1928a9e69d14851110c47590814ba8878f4e00000003000006dc
---
title: from json
categories: |
  formats
version: 0.104.0
formats: |
  Convert from json to structured data.
usage: |
  Convert from json to structured data.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `from json` for [formats](/commands/categories/formats.md)

<div class='command-title'>Convert from json to structured data.</div>

## Signature

```> from json {flags} ```

## Flags

 -  `--objects, -o`: treat each line as a separate value
 -  `--strict, -s`: follow the json specification exactly


## Input/output types:

| input  | output |
| ------ | ------ |
| string | any    |
## Examples

Converts json formatted string to table
```nu
> '{ "a": 1 }' | from json
╭───┬───╮
│ a │ 1 │
╰───┴───╯
```

Converts json formatted string to table
```nu
> '{ "a": 1, "b": [1, 2] }' | from json
╭───┬───────────╮
│ a │ 1         │
│   │ ╭───┬───╮ │
│ b │ │ 0 │ 1 │ │
│   │ │ 1 │ 2 │ │
│   │ ╰───┴───╯ │
╰───┴───────────╯
```

Parse json strictly which will error on comments and trailing commas
```nu
> '{ "a": 1, "b": 2 }' | from json -s
╭───┬───╮
│ a │ 1 │
│ b │ 2 │
╰───┴───╯
```

Parse a stream of line-delimited JSON values
```nu
> '{ "a": 1 }
{ "b": 2 }' | from json --objects
╭───┬────┬────╮
│ # │ a  │ b  │
├───┼────┼────┤
│ 0 │  1 │ ❎ │
│ 1 │ ❎ │  2 │
╰───┴────┴────╯

```

Chunks
2c7b5ac1 (1st chunk of `commands/docs/from_json.md`)
Title: from json
Summary
The `from json` command in Nushell is used to convert JSON formatted strings into structured data that can be manipulated within Nushell. It is particularly useful for working with APIs or configuration files that use JSON as their primary data format. The command can parse a single JSON string, or, when used with the `--objects` or `-o` flag, it can process a stream of line-delimited JSON values, treating each line as a separate JSON object. When parsing, the command can also be configured to operate in strict mode, enabled by the `--strict` or `-s` flag. In strict mode, the parser will adhere strictly to the JSON specification, which means it will throw errors if it encounters comments or trailing commas, which are often tolerated in less strict JSON parsing environments. This command enables robust and reliable data transformation from JSON into Nushell's data structures.