»Import: json

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


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)


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.