Skip to main content

JsonAsTree Namespace

Utilities for storing JSON data in TreeNodes.

This API is provided as an alpha preview and may change without notice.

To use, import via @fluidframework/tree/alpha.

For more information about our API support guarantees, see here.

Signature

export declare namespace JsonAsTree

Remarks

Schema which replicate the JSON data model with TreeNodes.

This allows JSON to be losslessly round-tripped through a tree with the following limitations:

  1. Only information that would be preserved by JSON.parse is preserved. This means (among other things) that numbers are limited to JavasScript's numeric precision.
  1. The order of fields on an object is not preserved. The resulting order is arbitrary.

JSON data can be imported from JSON into this format using JSON.parse then importConcise(schema, data) with the Tree schema.

Classes

ClassAlertsModifiersDescription
ArrayAlphasealedArbitrary JSON array as a TreeNode.
JsonObjectAlphasealedArbitrary JSON object as a TreeNode.

Types

TypeAliasAlertsDescription
_RecursiveArrayWorkaroundJsonArraySystemD.ts bug workaround, see FixRecursiveArraySchema.
PrimitiveAlphaAllowedTypes for primitives types allowed in JSON.
TreeAlphaAllowedTypes for any content allowed in the JsonAsTree domain.

Variables

VariableAlertsModifiersTypeDescription
_APIExtractorWorkaroundArrayBaseSystemreadonlyArrayNodeCustomizableSchemaUnsafe<"com.fluidframework.json.array", readonly [LeafSchema<"null", null>, LeafSchema<"number", number>, LeafSchema<"string", string>, LeafSchema<"boolean", boolean>, () => typeof JsonObject, () => typeof Array], unknown>Do not use. Exists only as a workaround for https://github.com/microsoft/TypeScript/issues/59550 and https://github.com/microsoft/rushstack/issues/4429.
_APIExtractorWorkaroundObjectBaseSystemreadonlyTreeNodeSchemaClass<"com.fluidframework.json.object", NodeKind.Record, TreeRecordNodeUnsafe<readonly [LeafSchema<"null", null>, LeafSchema<"number", number>, LeafSchema<"string", string>, LeafSchema<"boolean", boolean>, () => typeof JsonObject, () => typeof Array]> & WithType<"com.fluidframework.json.object", NodeKind.Record, unknown>, { readonly [x: string]: string | number | JsonObject | Array | System_Unsafe.InsertableTypedNodeUnsafe<LeafSchema<"boolean", boolean>, LeafSchema<"boolean", boolean>> | null; }, false, readonly [LeafSchema<"null", null>, LeafSchema<"number", number>, LeafSchema<"string", string>, LeafSchema<"boolean", boolean>, () => typeof JsonObject, () => typeof Array], undefined, unknown>Do not use. Exists only as a workaround for https://github.com/microsoft/TypeScript/issues/59550 and https://github.com/microsoft/rushstack/issues/4429.
PrimitiveAlphareadonlyreadonly [LeafSchema<"null", null>, LeafSchema<"number", number>, LeafSchema<"string", string>, LeafSchema<"boolean", boolean>]AllowedTypes for primitives types allowed in JSON.
TreeAlphareadonlyreadonly [LeafSchema<"null", null>, LeafSchema<"number", number>, LeafSchema<"string", string>, LeafSchema<"boolean", boolean>, () => typeof JsonObject, () => typeof Array]AllowedTypes for any content allowed in the JsonAsTree domain.

Variable Details

_APIExtractorWorkaroundArrayBase

Do not use. Exists only as a workaround for https://github.com/microsoft/TypeScript/issues/59550 and https://github.com/microsoft/rushstack/issues/4429. \

This API is reserved for internal system use and should not be imported directly. It may change at any time without notice.

For more information about our API support guarantees, see here.

Signature

_APIExtractorWorkaroundArrayBase: ArrayNodeCustomizableSchemaUnsafe<"com.fluidframework.json.array", readonly [LeafSchema<"null", null>, LeafSchema<"number", number>, LeafSchema<"string", string>, LeafSchema<"boolean", boolean>, () => typeof JsonObject, () => typeof Array], unknown>

Type: ArrayNodeCustomizableSchemaUnsafe<"com.fluidframework.json.array", readonly [LeafSchema<"null", null>, LeafSchema<"number", number>, LeafSchema<"string", string>, LeafSchema<"boolean", boolean>, () => typeof JsonObject, () => typeof Array], unknown>

_APIExtractorWorkaroundObjectBase

Do not use. Exists only as a workaround for https://github.com/microsoft/TypeScript/issues/59550 and https://github.com/microsoft/rushstack/issues/4429. \

This API is reserved for internal system use and should not be imported directly. It may change at any time without notice.

For more information about our API support guarantees, see here.

Signature

_APIExtractorWorkaroundObjectBase: TreeNodeSchemaClass<"com.fluidframework.json.object", NodeKind.Record, TreeRecordNodeUnsafe<readonly [LeafSchema<"null", null>, LeafSchema<"number", number>, LeafSchema<"string", string>, LeafSchema<"boolean", boolean>, () => typeof JsonObject, () => typeof Array]> & WithType<"com.fluidframework.json.object", NodeKind.Record, unknown>, {
readonly [x: string]: string | number | JsonObject | Array | System_Unsafe.InsertableTypedNodeUnsafe<LeafSchema<"boolean", boolean>, LeafSchema<"boolean", boolean>> | null;
}, false, readonly [LeafSchema<"null", null>, LeafSchema<"number", number>, LeafSchema<"string", string>, LeafSchema<"boolean", boolean>, () => typeof JsonObject, () => typeof Array], undefined, unknown>

Type: TreeNodeSchemaClass<"com.fluidframework.json.object", NodeKind.Record, TreeRecordNodeUnsafe<readonly [LeafSchema<"null", null>, LeafSchema<"number", number>, LeafSchema<"string", string>, LeafSchema<"boolean", boolean>, () => typeof JsonObject, () => typeof Array]> & WithType<"com.fluidframework.json.object", NodeKind.Record, unknown>, { readonly [x: string]: string | number | JsonObject | Array | System_Unsafe.InsertableTypedNodeUnsafe<LeafSchema<"boolean", boolean>, LeafSchema<"boolean", boolean>> | null; }, false, readonly [LeafSchema<"null", null>, LeafSchema<"number", number>, LeafSchema<"string", string>, LeafSchema<"boolean", boolean>, () => typeof JsonObject, () => typeof Array], undefined, unknown>

Primitive

AllowedTypes for primitives types allowed in JSON.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature

Primitive: readonly [LeafSchema<"null", null>, LeafSchema<"number", number>, LeafSchema<"string", string>, LeafSchema<"boolean", boolean>]

Type: readonly [LeafSchema<"null", null>, LeafSchema<"number", number>, LeafSchema<"string", string>, LeafSchema<"boolean", boolean>]

Tree

AllowedTypes for any content allowed in the JsonAsTree domain.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature

Tree: readonly [LeafSchema<"null", null>, LeafSchema<"number", number>, LeafSchema<"string", string>, LeafSchema<"boolean", boolean>, () => typeof JsonObject, () => typeof Array]

Type: readonly [LeafSchema<"null", null>, LeafSchema<"number", number>, LeafSchema<"string", string>, LeafSchema<"boolean", boolean>, () => typeof JsonObject, () => typeof Array]

Example

const tree = TreeBeta.importConcise(JsonAsTree.Union, { example: { nested: true }, value: 5 });