WhiteflagProtocol / whiteflag-java

Implementation of the Whiteflag protocol for Java development
https://java.whiteflagprotocol.org
Other
2 stars 2 forks source link

Support for JSON formatted messages #3

Closed ts5746 closed 3 years ago

ts5746 commented 3 years ago

Description

The Whiteflag Java Library should be able to export and import messages from and to a JSON format.

Rationale

To exchange Whiteflag messages and be interoperable with other software, the JSON language-independent open data interchange format should be natively supported by the WFJL. In addition, the Whiteflag standard provides a JSON schema of the Whiteflag message structure and syntax interoperable implementation of the standard.

Solution

Specification

Affected components

t.b.d.

Alternatives

Alternatively, the conversion of message to and from a JSON representation should be performed by other software. It is, however, the purpose of the WFJL to support the development of Whiteflag-enabled applications by providing a standardised solution as much as possible.

ts5746 commented 3 years ago

This feature has been implemented with the WfJsonMessage class in the org.whiteflag.protocol.util package, which is used by the WfMessage class. The solution is based on the jackson JSON library that has been added as a dependency. Usage:

import org.whiteflag.protocol.WfMessage;

WfMessage message = WfMessage.Creator.deserializeJson(jsonString);
String jsonMessage = message.toJson();
ts5746 commented 3 years ago

JSON message schema check still needs to be added.

ts5746 commented 3 years ago

The syntax checks against the Whiteflag JSON message schema will be added in version 1.2 and tracked separately.