Skip to content

OK JSON

OK JSON is a JSON viewer. Protocol Launcher allows you to generate OK JSON URL scheme links.

Usage

There are two ways to use this library:

  • On-Demand import from subpaths enables tree-shaking and keeps bundles small.
  • Full Import from the root package is convenient but includes all app modules.

Pick On-Demand for production builds; Full Import is fine for quick scripts or demos.

Select Installation Method

On-Demand
Recommended. Optimized for production.
Full Import
Convenient. Good for quick scripts.

Notes

OK JSON's official URL Schemes page documents five actions: okjson://paste, okjson://new?content=..., okjson://history, okjson://scripts-panel, and okjson://script/.... This module only exposes helpers for those documented actions.

newJson() accepts a raw JSON string and serializes it as the official URL-encoded content query parameter. runScript() accepts the custom script file name without the .js extension, matching the official script URL format.

View JSON String from Pasteboard

On-Demand
ts
import { paste } from 'protocol-launcher/ok-json'

const url = paste()

View JSON String

On-Demand
ts
import { newJson } from 'protocol-launcher/ok-json'

const url = newJson({
  content: '{"hello":"world"}',
})

Show History Window

On-Demand
ts
import { history } from 'protocol-launcher/ok-json'

const url = history()

Show Scripts Panel Window

On-Demand
ts
import { scriptsPanel } from 'protocol-launcher/ok-json'

const url = scriptsPanel()

Run Script

On-Demand
ts
import { runScript } from 'protocol-launcher/ok-json'

const url = runScript({
  scriptFileNameWithoutJsExtension: 'copy-minified-json',
})

Generated URLs

ts
paste()
// => 'okjson://paste'

newJson({
  content: '{"hello":"world"}',
})
// => 'okjson://new?content=%7B%22hello%22%3A%22world%22%7D'

history()
// => 'okjson://history'

scriptsPanel()
// => 'okjson://scripts-panel'

runScript({
  scriptFileNameWithoutJsExtension: 'copy-minified-json',
})
// => 'okjson://script/copy-minified-json'

Official Documentation