Package io.openems.common.jsonrpc.base
Class JsonrpcMessage
- java.lang.Object
-
- io.openems.common.jsonrpc.base.JsonrpcMessage
-
- Direct Known Subclasses:
AbstractJsonrpcRequest
,JsonrpcResponse
public abstract class JsonrpcMessage extends java.lang.Object
Represents a JSON-RPC Message.{ "jsonrpc": "2.0", ... }
- See Also:
- JSON-RPC specification
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
JSONRPC_VERSION
-
Constructor Summary
Constructors Constructor Description JsonrpcMessage()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JsonrpcMessage
from(com.google.gson.JsonObject j)
Parses aJsonObject
to aJsonrpcMessage
.static JsonrpcMessage
from(java.lang.String json)
Parses a JSON String to aJsonrpcMessage
.com.google.gson.JsonObject
toJsonObject()
Gets theJsonObject
representation of thisJsonrpcMessage
.java.lang.String
toString()
Returns this JsonrpcMessage as a JSON String.
-
-
-
Field Detail
-
JSONRPC_VERSION
public static final java.lang.String JSONRPC_VERSION
- See Also:
- Constant Field Values
-
-
Method Detail
-
from
public static JsonrpcMessage from(java.lang.String json) throws OpenemsError.OpenemsNamedException
Parses a JSON String to aJsonrpcMessage
.- Parameters:
json
- the JSON String- Returns:
- the
JsonrpcMessage
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
from
public static JsonrpcMessage from(com.google.gson.JsonObject j) throws OpenemsError.OpenemsNamedException
Parses aJsonObject
to aJsonrpcMessage
.- Parameters:
j
- theJsonObject
- Returns:
- the
JsonrpcMessage
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
toJsonObject
public com.google.gson.JsonObject toJsonObject()
Gets theJsonObject
representation of thisJsonrpcMessage
.- Returns:
- a
JsonObject
-
toString
public java.lang.String toString()
Returns this JsonrpcMessage as a JSON String.- Overrides:
toString
in classjava.lang.Object
-
-