public class

JsonFormatter

extends Object
java.lang.Object
   ↳ com.openxc.messages.formatters.JsonFormatter

Class Overview

A formatter for serializing and deserializing JSON OpenXC messages.

Summary

Public Constructors
JsonFormatter()
Public Methods
static VehicleMessage deserialize(String data)
Deserialize a single vehicle messages from the string.
static String serialize(VehicleMessage message)
Serialize a vehicle message to a string.
static String serialize(Collection<VehicleMessage> messages)
Serialize a collection of messages to a string.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public JsonFormatter ()

Public Methods

public static VehicleMessage deserialize (String data)

Deserialize a single vehicle messages from the string.

Parameters
data a String containing the JSON serialized vehicle message.
Returns
  • the deserialized VehicleMessage.
Throws
UnrecognizedMessageTypeException if no message could be deserialized.

public static String serialize (VehicleMessage message)

Serialize a vehicle message to a string.

Parameters
message the message to serialize
Returns
  • the message serialized to a String.

public static String serialize (Collection<VehicleMessage> messages)

Serialize a collection of messages to a string. Each message will be serialized to a JSON object, and they will all be included in a JSON array in the result.

Parameters
messages the messages to serialize.
Returns
  • the messages serialized individually and in a JSON array.