Previous Topic

Next Topic

Book Contents

Book Index

Technology Overview

JavaScript Object Notation – Remote Procedure Call or JSON-RPC defines a handful of data types and commands. The general mechanism consists of two peers establishing a data connection. During the lifetime of a connection, peers may invoke methods provided by the other peer. To invoke a remote method, a request is sent. Unless the request is a notification it must be replied to with a response.

Request

A remote method is invoked by sending a request to a remote service. The request is a single object serialized using JSON.

It has three properties:

Response

When the invocation method completes, the service must reply with a response. The response is a single object serialized using JSON.

It has three properties:

Notification

A notification is a special request which does not have a response. It is a single object serialized using JSON.

The notification has the same properties as the request object with one exception – the id must be null.

JSON-RPC Data Types

There are only simple data types defined in JSON. To overcome this problem in a JSON compatible way a special property for objects is introduced – {"__jsonclass__":["constructor", [param1,...]], "prop1": ...} The object is then instantiated using the constructor, passing in the parameters. Once constructed, the (prop1, ...) properties will be applied.

Examples