PipeWire SPA(Simple Plugin API) JSON in JavaScript
$ # Yarn
$ yarn add spa-json
$ # or NPM
$ npm i spa-json
import { parse, stringify } from 'spa-json'
const obj = parse(`
context.properties = {
core.daemon = true
core.name = pipewire-0
default.clock.rate = 48000
default.clock.allowed-rates = [
44100 48000 96000
]
}
context.modules = [
# ...
]
# ...
`)
const text = stringify(obj)
// import assert from 'assert'
// assert.deepEqual(parse(text), obj)
The api is basically the same as JSON.parse()
and JSON.stringify()
except we have a noWrap
as the 4th parameter of stringify()
by which strips top-level wrapper {
}
.
For detailed documentation, see type definitions.
For example usage, see test/parse.js and test/stringify.js.
- implement
stringify()
- maybe add AST support for better config manipulating