Skip to content

dbus: add preliminary support for JSON encoded messages#423

Draft
dvdhrm wants to merge 1 commit intobus1:mainfrom
dvdhrm:wip/json
Draft

dbus: add preliminary support for JSON encoded messages#423
dvdhrm wants to merge 1 commit intobus1:mainfrom
dvdhrm:wip/json

Conversation

@dvdhrm
Copy link
Member

@dvdhrm dvdhrm commented Jan 9, 2026

Use the new D-Bus and JSON modules in sys/tmp to allow clients with JSON-based encoding.

This extends the D-Bus socket layer to support zero-byte separated, variable-width message objects. This is then used to get a stream of JSON objects.

JSON objects are always converted to the internally used format (for now DVariant). This keeps modifications to the code-base much simpler and guarantees that all paths work with the same data. Outgoing messages are then converted again directly in the socket layer.

If we decide to fully commit to the new D-Bus module and convert all users in bus/driver/, then we can avoid the conversion in most cases. However, for broadcast/multicast messages, we always want to convert messages to ensure each clients gets the properly encoded message.

NB: This is preliminary. The conversion from DVariant to JSON is not
standardized, nor do we want to commit to it right now. However, we
want to get feedback and give developers the chance to make use of
it.
We definitely intend to stabilize this in the near future.

Use the new D-Bus and JSON modules in `sys/tmp` to allow clients with
JSON-based encoding.

This extends the D-Bus socket layer to support zero-byte separated,
variable-width message objects. This is then used to get a stream of
JSON objects.

JSON objects are always converted to the internally used format (for now
DVariant). This keeps modifications to the code-base much simpler and
guarantees that all paths work with the same data. Outgoing messages are
then converted again directly in the socket layer.

If we decide to fully commit to the new D-Bus module and convert all
users in `bus/driver/`, then we can avoid the conversion in most cases.
However, for broadcast/multicast messages, we always want to convert
messages to ensure each clients gets the properly encoded message.

NB: This is preliminary. The conversion from DVariant to JSON is not
    standardized, nor do we want to commit to it right now. However, we
    want to get feedback and give developers the chance to make use of
    it.
    We definitely intend to stabilize this in the near future.

Signed-off-by: David Rheinsberg <david@readahead.eu>
* must be native-endian, so: big_endian if (__BYTE_ORDER == __BIG_ENDIAN)
*/

if (n_data > MESSAGE_SIZE_MAX)

Check warning

Code scanning / CodeQL

Comparison result is always the same Warning

Comparison is always false because n_data <= 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant