Just a second...

JSON topics

A topic that provides data in JavaScript Object Notation (JSON) format. The data is transmitted in a binary form for increased efficiency. JSON topics are stateful: their state is maintained on the Diffusion™ server.

Note: JSON topics are fully supported by the JavaScript® Unified API, Android™ Unified API, Java™ Unified API, and .NET Unified API,

Why use a JSON topic?

JSON provides the ability for you to structure your data in a human-readable, industry-standard format. For more information about JSON, see http://www.json.org/.

The value of the topic is transmitted as Concise Binary Object Representation (CBOR). For more information about CBOR, see http://cbor.io/.

The value of the topic is accessible both as JSON and CBOR.

Why use a JSON topic?

JSON is a human-readable, industry-standard format for your data. JSON is natively supported by JavaScript and there are third-party libraries available for other platforms.

A JSON topic enables multiple fields to be maintained in the same topic as part of a composite data type. All updates made at the same time to parts of a JSON topic are sent out to the client together. This enables a set of parts to be treated as a transactional group.

Deltas of change are calculated at the Diffusion server such that only those parts that have changed since the last update are sent out to the subscribed clients. This ensures that the minimum amount of data is sent to clients.

The current value of the topic is cached on the client. When deltas are sent, the client can automatically apply these deltas to the value to calculate the new value.

If your data structure is too complex to be represented by a topic tree or might make the topic tree structure difficult to manage, it might be more appropriate to represent part of the data structure inside a JSON topic as JSON objects.

Properties of a JSON topic

When you create a JSON topic you can specify the following properties in the topic specification:
PUBLISH_VALUES_ONLY
If set to true, all values are published in full. Otherwise, deltas are published if they are more efficient to send than the full values.

If there is little or no relationship between values published to a topic, delta streams will not reduce the amount of data transmitted. For such topics, it is better to set PUBLISH_VALUES_ONLY.

VALIDATE_VALUES
If set to true, the topic checks that the update made to it by an updating client is a valid instance of the JSON datatype. If the update is not valid, the update is discarded and the updating client notified of the failure.

If set to anything other than true, no validation is performed and all values are streamed to subscribing clients whether they are valid JSON data or not.

Validation has a performance overhead and is disabled by default.

Considerations when using a JSON topic

JSON is only native to JavaScript. Other languages must parse it as text. However, there are many third-party libraries you can use for this parsing.

JSON does not support binary data. If you want to use binary data, you can use binary topics. For more information, see Binary topics.

Classic API clients (deprecated) do not support any interaction with JSON topics.

JSON topics are currently fully supported by only the following APIs:
  • JavaScript Unified API
  • Java Unified API
  • Android Unified API
  • .NET Unified API
The following APIs offer limited support:
  • C Unified API
  • Apple® Unified API

    Use this API to create JSON topics and to receive data from JSON topics. Updating JSON topics is not yet fully supported.

The Publisher API provides the capability to create and update JSON topics using TopicDataFactory.newUniversalData.

If you use value streams to receive updates from a JSON topic, this can cause problems in the event of client reconnection. We recommend that when using value streams, you configure your clients not to attempt to reconnect to a session, but instead to connect again with a new session and resubscribe to topics.