Pengutronix

  • About Pengutronix
  • Events
  • News / Press
  • Contact & Imprint

Embedded Linux

  • Consulting
  • Training
  • Development

Community

  • Mailing Lists
  • Open Source Projects
  • Debian Packages
  • www.ptxdist.org
  • www.send-patches.org
lang:en   [IPv4/6]   lang:de


JSON-D-BUS-Bridge

The JSON-D-Bus-Bridge Logo

The JSON-D-Bus-bridge is a fastcgi application that provides access to D-Bus.

It accepts JSON-RPC calls as used for instance by qooxdoo and translates these into D-Bus calls. Any response is converted back to JSON and sent to the client.

The bridge is completely generic. New D-Bus services can be added without modifications to the bridge.

License: LGPLv2.1

About

Download

  • Tarball Releases
  • Git Tree
  • Git Tree (Examples)

JSON-D-Bus-Bridge allows the combination of state-of-the-art browser-based user interfaces with the power and simplicity of D-Bus inter process communication. JavaScript Frameworks such as qooxdoo provide an extensive API for creating fully object oriented browser-based applications, including advanced RPC mechanisms, which can be easily used with the JSON-D-Bus-Bridge. The inter-process communication system D-Bus is supported by most POSIX-based operating systems, such as Unix and Linux, and provides a low-footprint middleware for easily managing processes and devices. It performs even on devices with relatively low computing power, such as cost sensitive embedded platforms.

Current Revision

The current stable release of JSON-D-Bus-Bridge is 1.0.0

Object Identification

According to the D-Bus data model, a method of an object on the message bus is identified by the following parts:

  • bus name
  • object path
  • interface
  • method

As the JSON-RPC used by qooxdoo does only know a "service" and a "method", a mapping has to be introduced by the JSON-D-Bus-Bridge, which makes it possible to specify all parts of a D-Bus method. The mapping looks like this:

service:<bus name>|<object path>
method:<interface>.<method>

Parameter Encoding

To make a successful D-Bus call, all parameters must be encoded with the correct type. Unfortunately not all D-Bus types can be uniquely mapped to a JSON type. E.g. int32, uint32, int16, ... are all mapped to a JSON number.

To generate the correct D-Bus message, the JSON-RPC call must contain an extra first parameter with the D-Bus signature of the parameters as defined by the D-Bus Specification. For the result the signature is skipped.

A simple call of a D-Bus method via JSON-RPC could look like this:

request = {
  "id": 1,
  "service":"org.examle|/",
  "method":"org.Example.Echo"
  "params": [ "s", "Hello World!" ]
}

response = {
  "id": 1,
  "error": null,
  "result": "Hello World!"
}
  

Variants are handled the same way. A variant value is an array with two elements: the variant signature and the actual value. Note that the variant can only contain single complete types. For returned variants, the signature is skipped as well.

Calling a method with one variant as parameter and a variant as return value, could look like this:

request = {
  "id": 1,
  "service":"org.examle|/",
  "method":"org.Example.VariantEcho"
  "params": [ "v", [ "s", "Hello World!" ] ]
}

response = {
  "id": 1,
  "error": null,
  "result": "Hello World!"
}
  

Limitations

The bridge is currently not able to handle all D-Bus features:

  • D-Bus Dictionaries are translated into JSON objects. As a result only dictionaries with string keys can be used.
  • Translation of structs is not yet implemented.
  • D-Bus signals are not yet supported.

Mailing List

The JSON-D-Bus-Bridge developer mailinglist shall be used for all kind of feedback and patches:

[ Subscribe via EMail ] 
[ Unsubscribe via EMail ]

Git Access

The source code can be checked out from the Pengutronix git Server. If access to the "git" protocol is not possible, http is also supported.

$ git clone git://git.pengutronix.de/git/json-dbus-bridge.git
$ git clone git://git.pengutronix.de/git/json-dbus-bridge-examples.git
  

Links

  • JSON Project
  • JSON-RPC Project
  • D-Bus on freedesktop.org
  • Qooxdoo
Last change: Wed May 11 12:49:31 2011
© Pengutronix e.K.
http://www.pengutronix.de