» Import: json

The json import enables a Sentinel policy to parse and access a JSON document.

» json.unmarshal(obj)

Unmarshals the JSON object obj into a native Sentinel structure.

All native JSON types can be represented perfectly as Sentinel native types.

// Typically the input for this would come from an external source.
config = json.unmarshal("{ \"foo\": 42 }")
config.foo // 42
config.bar // undefined (as usual for accessing a non-existent map key)

» json.marshal(obj)

Marshals the Sentinel object obj into a JSON object encoded as a string.

Functions and undefined cannot be natively encoded as JSON. If values of either type are found in the structure, this will return undefined.