public

Working with JSON

read-only

AI authored to showcase ironpad capabilities.

Working with JSON 🔮

ironpad has a built-in Json display type that pretty-prints JSON with syntax highlighting. It's great for exploring API responses, configuration data, or any structured data.

The Json type wraps a serde_json::Value and renders it with color-coded keys, strings, numbers, and booleans.

[1]Basic JSON
1 panel
Saved output from the author's last run. Press Run to execute live in your browser.
{
  "features": [
    "wasm",
    "notebooks",
    "charts"
  ],
  "name": "ironpad",
  "stats": {
    "cells_compiled": 42,
    "is_awesome": true,
    "tests_passing": 190
  },
  "version": "0.1.0"
}

Parsing JSON Strings

You can create a Json value from a raw string using the standard str::parse() method or serde_json::from_str.

[2]Parse Example
1 panel
Saved output from the author's last run. Press Run to execute live in your browser.
{
  "page": null,
  "total": 3,
  "users": [
    {
      "active": true,
      "id": 1,
      "name": "Alice"
    },
    {
      "active": false,
      "id": 2,
      "name": "Bob"
    },
    {
      "active": true,
      "id": 3,
      "name": "Charlie"
    }
  ]
}

JSON + HTTP

Combine Json with ironpad's HTTP helpers to fetch and display API responses beautifully.

[3]Fetch & Display
1 panel
Saved output from the author's last run. Press Run to execute live in your browser.
{
  "args": {},
  "headers": {
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate, br, zstd",
    "Host": "httpbin.org",
    "Origin": "http://localhost:3111",
    "Priority": "u=1, i",
    "Referer": "http://localhost:3111/",
    "Sec-Fetch-Dest": "empty",
    "Sec-Fetch-Mode": "cors",
    "Sec-Fetch-Site": "cross-site",
    "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/145.0.7632.6 Safari/537.36",
    "X-Amzn-Trace-Id": "Root=1-6a7f6904-5c51e60678040b9f28d13416"
  },
  "origin": "174.164.136.150",
  "url": "https://httpbin.org/get"
}

Typed Data → JSON

You can also serialize your own Rust structs into Json for display. This is handy for inspecting complex data structures.

[4]Struct to JSON
1 panel
Saved output from the author's last run. Press Run to execute live in your browser.
[
  {
    "language": "Rust",
    "name": "ironpad",
    "stars": 128,
    "topics": [
      "wasm",
      "notebook"
    ]
  },
  {
    "language": "Rust",
    "name": "plotters",
    "stars": 4200,
    "topics": [
      "visualization",
      "svg"
    ]
  }
]