Introducing a new way to review your PRs.

Read the announcement

visgl / deck.gl

WebGL2 powered visualization framework

View on GitHub

23 documents · Updated Nov 20, 2026

docs / json-specification

JSON specification

The @deck.gl/json package turns a serialized description of a deck.gl scene into the props and runtime components that deck.gl can render. It keeps JSON close to normal deck.gl props while adding a declarative way to name layers, views, nested components, accessors, constants, enums, and functions. This lets tools such as the playground and Jupyter widget share one scene format without creating a separate rendering model. See the data and visualization extensions page for the wider extension model.

Declarative visualization model

Serialized deck description

The JSON document describes a deck.gl configuration as a plain object. Top-level values such as initialViewState, views, and layers map to the matching deck.gl props. Each typed entry names a runtime component and supplies the values that configure it.

The format also supports nested component descriptions. A layer can contain typed extensions. An effect can contain typed lights. A view can appear in a view layout. The same conversion rules apply at each level, so one serialized value can describe a complete scene.

{
  "initialViewState": {"longitude": -122.45, "latitude": 37.8, "zoom": 12},
  "views": [{"@@type": "MapView", "controller": true}],
  "layers": [
    {
      "@@type": "ScatterplotLayer",
      "data": [{"position": [-122.45, 37.8]}],
      "getPosition": "@@=position",
      "getRadius": 1000
    }
  ]
}

The package converts values. It does not validate every layer prop or define a second layer API. After conversion, the deck.gl component still gives each prop its meaning. A host supplies the catalogs that decide which names can become executable components.

References: modules/…/README.md• L1-5 modules/…/package.json• L1-5 modules/…/json-converter.ts• L25-35 examples/…/schema.ts• L887-904 test/…/deck-props.json• L1-57

Type and property mapping

Type references

@@type identifies a runtime class or component by its catalog name. The converter removes this marker, converts the remaining props, and creates the registered JavaScript class or React element. Since conversion is recursive, a typed object can appear wherever a deck.gl prop expects a layer, view, extension, effect, or other component.

The catalog connects serialized names to executable code. A name works only when the host registers it in classes or reactComponents. An unknown name produces a warning and a null result instead of a component, which lets the host decide how to handle incomplete input.

References: modules/…/json-converter.ts• L145-160 modules/…/json-converter.ts• L172-201 modules/…/instantiate-class.ts• L14-43 modules/…/json-configuration.ts• L26-45

Property values

Most JSON values keep their normal meaning. The converter walks objects and arrays recursively. Plain data stays plain data. A marker creates a runtime value only when the marker is present. This lets one layer combine fixed settings with data-driven props.

JSON formRuntime meaningTypical use
"@@type": "ScatterplotLayer"An instance of the registered typeSelect a layer or nested component
"@@=position"An accessor function evaluated with a data rowRead a field for getPosition
"@@=[lon, lat]"An accessor expressionBuild a value from row fields
"@@#COORDINATE_SYSTEM.METER_OFFSETS"A registered enum valueSet a deck.gl enum prop
"@@#MapController"A registered constantReuse a runtime constant
{ "@@function": "calculateRadius", "base": 10 }The result of a registered functionCompute a configured value

Accessor expressions use a restricted data expression language. @@=- is the identity accessor. A path such as @@=feature.geometry.type reads nested data. Expressions can use data values, literals, indexing, and operators. They cannot call functions.

References: modules/…/syntactic-sugar.ts• L5-8 modules/…/json-converter.ts• L242-266 modules/…/convert-functions.ts• L11-51 modules/…/parse-expression-string.ts• L24-63 test/…/complex-data.json• L8-90

Conversion lifecycle

JSON conversion flow

JSONConverter accepts a parsed object or a JSON string and returns a value that a deck.gl host can use. It turns the input into a tree of plain values, accessors, constants, function results, and instantiated components. An optional configuration hook can adjust the converted result before the host uses it.

The diagram shows how serialized layer configuration becomes executable deck.gl props.

flowchart LR
  A[JSON string or object] --> B[Parse input]
  B --> C[Walk arrays and objects]
  C --> D{Special marker?}
  D -->|@@type| E[Resolve catalog entry and instantiate]
  D -->|@@=| F[Compile data accessor]
  D -->|@@#| G[Resolve constant or enum]
  D -->|@@function| H[Call registered function]
  D -->|none| I[Keep plain value]
  E --> J[Converted deck props]
  F --> J
  G --> J
  H --> J
  I --> J
  J --> K[Optional post-process]
  K --> L[Deck.gl rendering host]

The conversion context comes from JSONConfiguration. It supplies the names that can be resolved and optional hooks for class props and the final result. A host can add catalog entries later. This lets it load custom layer libraries without changing the serialized format.

References: modules/…/json-converter.ts• L89-114 modules/…/json-converter.ts• L132-169 modules/…/json-configuration.ts• L64-129 modules/…/create-deck.js• L71-80

Runtime handoff

After conversion, the host treats the result as ordinary deck.gl props. In the Jupyter playground, createDeck converts the input and passes the result to DeckGL. Later updates repeat the conversion before calling setProps. This keeps JSON parsing outside the rendering system and leaves rendering, picking, data loading, and layer behavior to deck.gl and its registered components.

A host can remove values that could not be resolved while a user edits JSON. The playground uses this step to keep invalid layers, views, and widgets out of the render call. Valid entries continue through the normal deck.gl lifecycle.

References: modules/…/create-deck.js• L128-130 modules/…/create-deck.js• L239-287 examples/…/configuration.ts• L58-70

JSON-facing component surface

Layer and view descriptions

The playground schema presents each supported layer as a JSON type with an explicit @@type value. It exposes the layer props that JSON can represent. Accessor props support either a direct value or an @@= expression. The resulting AnyLayer union gives the editor a known set of layer names while keeping normal deck.gl prop meaning.

Views use the same pattern. A view object names a registered view class and supplies view props as JSON. A deck description can therefore combine view state, view instances, and layer instances without a separate syntax for each component category.

The schema is a support list. It is not the source of runtime registration. Adding a name to the editor schema does not make it executable. The host must also map that name to a class or component.

References: examples/…/schema.ts• L7-23 examples/…/schema.ts• L110-121 examples/…/schema.ts• L151-197 examples/…/schema.ts• L684-718

Nested extensions and effects

Nested component values use the same @@type contract as top-level layers. This lets JSON describe a layer extension or lighting effect and hydrate it before the parent component receives its props. The parent layer then sees the same runtime extension object that code-created deck.gl props would use.

This relationship depends on complete registration. The Jupyter host registers extension, effect, light, view, and post-process types alongside layers. A serialized scene can then cross component boundaries without special JSON rules. See layer extensions for the role of extensions after hydration.

References: modules/…/create-deck.js• L43-67 test/…/create-deck.spec.ts• L66-135 modules/…/json-converter.ts• L150-160

Configuration catalogs

Runtime name catalogs

JSONConfiguration defines the vocabulary available to a JSON document. Class catalogs resolve @@type. Function catalogs resolve named @@function calls. Enumeration catalogs resolve grouped enum names. Constant catalogs resolve shared runtime values. These catalogs let each host expose only the components that it can safely construct.

The playground builds its catalog from deck.gl layer, view, widget, and Carto exports. It also adds Carto source functions and color helpers as named functions. Carto-specific JSON features therefore enter through the same general JSON model. See Carto integration for the data and layer features provided by Carto.

References: modules/…/json-configuration.ts• L24-45 examples/…/configuration.ts• L26-56 modules/…/create-deck.js• L43-67

Custom library registration

A host can merge new catalogs into an existing converter. The Jupyter playground uses this to add classes and functions from libraries loaded at runtime. It then retries conversion so unresolved layer or widget entries can become executable. The serialized document does not change when the library becomes available. Only the active catalog changes.

This model lets tools discover components outside the core deck.gl bundle. The host still controls which external code it trusts and which names it exposes.

References: modules/…/json-converter.ts• L80-85 modules/…/create-deck.js• L75-125 modules/…/create-deck.js• L249-287

Change checklist

When these files or sections are changed, remember to consider these:

  • When a layer, view, extension, effect, or widget name changes, update every host catalog that resolves the old @@type value. Keep any intentional alias for existing JSON documents.
  • When a new JSON-facing layer prop is added, check that it has a JSON-safe form and that the editor schema includes the same value or @@= accessor contract.
  • When a nested component becomes valid in JSON, register its class in the same host that registers the parent. Otherwise the parent can be dropped even when its own type is valid.
  • When a named function, enum group, or constant is added or renamed, update both the catalog and every serialized reference that uses its exact name.
  • When a post-process filter changes, confirm that newly supported component instances pass the host’s validity checks before they reach DeckGL.setProps.
  • When the package entry points or peer version changes in modules/…/package.json, check that consumers still load the intended build and use a compatible @deck.gl/core version.

Important failure modes

TriggerConsequenceGuard
A @@type name is missing from the active class or React catalogThe converter warns and returns null; a host filter can remove the layer, view, or nested componentRegister the type in the host configuration and keep schema names aligned with catalog names
A nested extension or effect type is not registeredThe parent may receive null for a required child or be rejected by host post-processingRegister all component types used inside serialized props, not only top-level layers
A @@function name is not in the function catalogThe configured value becomes null after a warningRegister the function before converting the document and preserve its serialized name
A @@= expression contains a function callConversion throws instead of creating an accessorUse data fields and supported operators only; keep executable calls in registered functions
The input is invalid JSON or its parsed value is not an objectParsing fails or conversion throws JSONConverter: expected an objectParse complete JSON objects before handing them to the converter
A @@# reference names an unavailable constant or enum groupConstant or enum resolution fails and the scene is not convertedAdd the value to the matching catalog and use the exact group and member names
A consumer uses an incompatible @deck.gl/core peer versionThe package may load with mismatched deck.gl runtime contractsKeep the consumer and @deck.gl/json on compatible deck.gl versions

Key files

FileWhy to read it
modules/…/package.jsonDefines the package boundary, published entry points, and deck.gl peer contract.
modules/…/json-converter.tsDefines the conversion contract from serialized values to runtime props and components.
modules/…/json-configuration.tsDefines the catalogs and hooks that decide which serialized names are executable.
modules/…/parse-expression-string.tsShows the safe accessor model behind @@= values.
modules/…/instantiate-class.tsShows how a registered @@type becomes a class instance or React element.
examples/…/schema.tsShows the JSON-facing layer, view, widget, and accessor surface used by the editor.
examples/…/configuration.tsShows how a host assembles deck.gl, Carto, loader, enum, and constant catalogs.
modules/…/create-deck.jsShows conversion, runtime catalog extension, and handoff to DeckGL.
test/…/complex-data.jsonProvides a compact example of typed layers, nested data, function values, and enum values.