Search guides and the APICtrl K
  1. API reference
  2. Data, text and crypto

json.h

JSON, and Base64, for state a plugin has to write down.

#include <sonore/json.h>
  • 2types
On this page

Design notes

Why the SDK needs a real one

The webview bridge builds JSON by concatenating strings and parses its own messages by hand. That is fine for a fixed message set with four fields and useless the moment a plugin has structured state to save: a sampler's key map, a modulation matrix, a list of user presets. StateBag holds strings, so today the only way to store a tree is to invent a format per plugin.

Where this stops

It parses and writes RFC 8259 JSON, with two deliberate limits stated rather than discovered: a nesting depth cap, because a plugin's state file may come from anywhere and a thousand open brackets is a stack overflow rather than a document; and numbers are all doubles, because JSON has no integer type and pretending otherwise is where every JSON library's edge cases live.

Types 2

A JSON value.

Objects keep their keys SORTED, because std::map does. That is a deliberate consequence rather than an accident: a plugin's state written twice from the same values produces byte-identical output, so a host can tell whether anything actually changed and a user can diff two preset files.

Base64, so binary state can live in a string.

StateBag holds strings and a host's state chunk is bytes, so a plugin with an impulse response or a wavetable to save has nowhere to put it. This is the standard alphabet with padding -- not the URL-safe variant, because nothing here puts state in a URL and two alphabets is two things to get wrong.

↑↓ to move↵ to openEvery public name in the headers, and every guide