TinyBase logoTinyBase

setValuesJson

The setValuesJson method takes a string serialization of all of the Values in the Store and attempts to update them to those values.

setValuesJson(valuesJson: Json): Store
TypeDescription
valuesJsonJson

A string serialization of all of the Values in the Store.

returnsStore

A reference to the Store.

If the JSON cannot be parsed, this will fail silently. If it can be parsed, it will then be subject to the same validation rules as the setValues method (according to the Values type, and matching any ValuesSchema associated with the Store).

Examples

This example sets the keyed value contents of a Store from a serialization.

const store = createStore();
store.setValuesJson('{"open": true}');
console.log(store.getValues());
// -> {open: true}

This example attempts to set the keyed value contents of a Store from an invalid serialization.

const store = createStore();
store.setValuesJson('{"open": false');
console.log(store.getValues());
// -> {}

Since

v3.0.0