TinyBase logoTinyBase β

getJson

The getJson method returns a string serialization of all the Store content: both the Tables and the keyed Values.

getJson(): string
returnsstring

A string serialization of the Tables and Values in the Store.

From v3.0 onwards, the serialization is of an array with two entries. The first is the Tables object, the second the Values. In previous versions (before the existence of the Values data structure), it was a sole object of Tables.

Examples

This example serializes the tabular and keyed value contents of a Store.

import {createStore} from 'tinybase';

const store = createStore()
  .setTables({pets: {fido: {species: 'dog'}}})
  .setValues({open: true});
console.log(store.getJson());
// -> '[{"pets":{"fido":{"species":"dog"}}},{"open":true}]'

This example serializes the contents of an empty Store.

import {createStore} from 'tinybase';

const store = createStore();
console.log(store.getJson());
// -> '[{},{}]'

Since

v1.0.0