Skip to main content

IFluidSerializer Interface

This API is provided for existing users, but is not recommended for new users.

To use, import via @fluidframework/shared-object-base/legacy.

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

Signature

export interface IFluidSerializer

Methods

MethodAlertsReturn TypeDescription
decode(input)Betaunknown

Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.

The original input object is not mutated. This method will shallowly clone all objects in the path from the root to any replaced handles. (If no handles are found, returns the original object.)

The decoded handles are implicitly bound to the handle context of this serializer.

encode(value, bind)Betaunknown

Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object where any embedded IFluidHandles have been replaced with a serializable form.

The original input object is not mutated. This method will shallowly clones all objects in the path from the root to any replaced handles. (If no handles are found, returns the original object.)

parse(value)BetaunknownParses the given JSON input string and returns the JavaScript object defined by it. Any Fluid handles will be realized as part of the parse
stringify(value, bind)BetastringStringifies a given value. Converts any IFluidHandle to its stringified equivalent.

Method Details

decode

Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.

The original input object is not mutated. This method will shallowly clone all objects in the path from the root to any replaced handles. (If no handles are found, returns the original object.)

The decoded handles are implicitly bound to the handle context of this serializer.

This API is provided for existing users, but is not recommended for new users.

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

Signature

decode(input: unknown): unknown;

Parameters

ParameterTypeDescription
inputunknown

Returns

Return type: unknown

encode

Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object where any embedded IFluidHandles have been replaced with a serializable form.

The original input object is not mutated. This method will shallowly clones all objects in the path from the root to any replaced handles. (If no handles are found, returns the original object.)

This API is provided for existing users, but is not recommended for new users.

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

Signature

encode(value: unknown, bind: IFluidHandle): unknown;

Parameters

ParameterTypeDescription
valueunknown
bindIFluidHandle

Returns

Return type: unknown

parse

Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid handles will be realized as part of the parse

This API is provided for existing users, but is not recommended for new users.

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

Signature

parse(value: string): unknown;

Parameters

ParameterTypeDescription
valuestring

Returns

Return type: unknown

stringify

Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.

This API is provided for existing users, but is not recommended for new users.

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

Signature

stringify(value: unknown, bind: IFluidHandle): string;

Parameters

ParameterTypeDescription
valueunknown
bindIFluidHandle

Returns

Return type: string