Closed ts5746 closed 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();
JSON message schema check still needs to be added.
The syntax checks against the Whiteflag JSON message schema will be added in version 1.2 and tracked separately.
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
WfMessage
class must have a method, e.g.toJSON()
that exports the message data to a stringified JSON objectWfMessage.Creator
class must have a method, e.g.fromJSON(jsonString)
that creates a new message from a stringified JSON objectAffected 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.