Skip to content

Examples

Mikkel102454 edited this page Oct 6, 2026 · 1 revision

Examples

Each JSON block below is a complete protocol 2.0 document. Return it directly from the configured HTTP endpoint.

Hello world

{
  "version": "2.0",
  "commands": [
    {
      "cmd": "clear",
      "args": {
        "color": "white"
      }
    },
    {
      "cmd": "draw_text",
      "args": {
        "x": 20,
        "y": 20,
        "width": 740,
        "height": 70,
        "spans": [
          {
            "text": "Hello, JSON Paper!",
            "family": "helvetica",
            "weight": "regular",
            "size": 32,
            "color": "black"
          }
        ]
      }
    }
  ]
}

Pie chart

Three slices represent 25% red, 35% yellow, and 40% black. Angles increase clockwise; 270° starts at the top.

{
  "version": "2.0",
  "commands": [
    {
      "cmd": "clear",
      "args": {
        "color": "white"
      }
    },
    {
      "cmd": "draw_pie_slice",
      "args": {
        "x": 200,
        "y": 135,
        "radius": 80,
        "start_angle": 270,
        "sweep_angle": 90,
        "color": "red"
      }
    },
    {
      "cmd": "draw_pie_slice",
      "args": {
        "x": 200,
        "y": 135,
        "radius": 80,
        "start_angle": 0,
        "sweep_angle": 126,
        "color": "yellow"
      }
    },
    {
      "cmd": "draw_pie_slice",
      "args": {
        "x": 200,
        "y": 135,
        "radius": 80,
        "start_angle": 126,
        "sweep_angle": 144,
        "color": "black"
      }
    }
  ]
}

Small indexed image

{
  "version": "2.0",
  "commands": [
    {
      "cmd": "clear",
      "args": {
        "color": "white"
      }
    },
    {
      "cmd": "draw_image",
      "args": {
        "x": 20,
        "y": 20,
        "width": 2,
        "height": 2,
        "data": "ASQ=",
        "transparent": 4
      }
    }
  ]
}

The image example is intentionally tiny: its pixels are black, white, yellow, and transparent. See Image Encoding to generate larger assets.

For dynamic responses, see PHP Library and Java Library. The repository also includes Server/hello-world.json, the PHP dashboard sample, and Java DashboardSample and RichTextSample classes.

Implementation references

Clone this wiki locally