Options
All
  • Public
  • Public/Protected
  • All
Menu

Class JSONImpl

Implementation of JSON object.

Hierarchy

  • any
    • JSONImpl

Implements

Index

Constructors

constructor

  • new JSONImpl(buffer: Buffer, offset?: number, length?: number): JSONImpl
  • Create a new JSONImpl instance

    Parameters

    • buffer: Buffer

      the internal buffer containing the JSON`

    • Default value offset: number = 0

      the offset of the data in the buffer

    • Default value length: number = buffer.length

      the number of bytes of the data in the buffer

    Returns JSONImpl

Methods

apply

  • Apply a delta to this JSON value to create a new value.

    Convenient equivalent to: diffusion.datatypes.JSON().deltaType(delta).apply(this, delta);

    throws

    an error if the delta is invalid

    Parameters

    Returns JSON

    a new instance derived from applying the delta to this value

binaryDiff

  • Compare this JSON value with an earlier version to create a structural json delta.

    Convenient equivalent to: this.diff(original, 'binary');

    Standard JSON objects may also be provided as the value to diff instead of a JSON instance.

    Example:

    const delta = binaryDiff.jsonDiff({ foo : 'bar' });

    Parameters

    • original: any

      the value to diff against this

    Returns BinaryDeltaImpl

    a delta representing the difference between this and the provided value

diff

get

  • get(): any
  • Get this instance's value. Use this method to access the provided data when a JSON instance is received through the API.

    Example:

    session.addStream('foo', diffusion.datatypes.json())
           .on('value', function(path, spec, value) {
        // Get the actual value from the JSON instance
        const data = value.get();
    });

    Returns any

    the JSON value

jsonDiff

  • Compare this JSON value with an earlier version to create a structural json delta.

    Convenient equivalent to: this.diff(original, 'json');

    Standard JSON objects may also be provided as the value to diff instead of a JSON instance.

    Example:

    const delta = jsonValue.jsonDiff({ foo : 'bar' });

    Parameters

    • original: any

    Returns JSONDeltaImpl

    a delta representing the difference between this and the provided value

toJsonString

  • toJsonString(): string
  • Convert the objet to a JSON string

    Returns string

    a JSON string representation of the JSON object

toString

  • toString(): string
  • Convert the objet to a string

    Returns string

    a string representation of the JSONImpl

Static from

  • Create a new JSON object from a raw object or a RecordV2Impl. If a RecordV2Impl is passed as argument it is simply returned.

    Parameters

    • value: any

      the object to create a JSON from

    Returns JSONImpl

    the JSON created

Static toString

  • toString(): string
  • Return the name of the data type

    Returns string

    JSONImpl