Skip to content

JsonObject

Create a JSON Object. An object can be created by providing a JS object value which will be serialized to JSON. Else, you can provide children that comprise the object’s JSON representation.

Overload 1

Create a JSON object by providing children that define the object’s contents. The children should use the JsonObjectProperty component to define individual object properties.

import { JsonObject } from "@alloy-js/json";
<JsonObject
refkey={Refkey | Refkey[]}
style={{
concise?: boolean;
}}
>
{children}
</JsonObject>

Props

childrenChildren

The contents of the JSON object. Likely to contain JsonObjectProperty components.

refkeyoptionalRefkey | Refkey[]

The refkey or array of refkeys for the JSON object. When provided, this value can be referenced elsewhere via this refkey.

styleoptional{ concise?: boolean; }

Overload 2

Create a JSON object by providing a JS value that will be serialized to JSON.

import { JsonObject } from "@alloy-js/json";
<JsonObject
jsValue={[string, unknown][] | Map<string, unknown> | Record<string, unknown>}
refkey={Refkey | Refkey[]}
style={{
concise?: boolean;
}}
/>

Props

jsValue[string, unknown][] | Map<string, unknown> | Record<string, unknown>

The JS value to serialize to JSON. This can be an array of key-value pairs, a map, or a vanilla JS object.

refkeyoptionalRefkey | Refkey[]

The refkey or array of refkeys for the JSON object. When provided, this value can be referenced elsewhere via this refkey.

styleoptional{ concise?: boolean; }

See also

  • [unresolved link]