T - the type of messagepublic interface JSONContext<T extends org.cometd.bayeux.Message.Mutable>
Abstraction for JSON parsing and generation.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
JSONContext.AsyncParser
A non-blocking JSON parser.
|
static interface |
JSONContext.Client
Client specific
JSONContext that binds to Message.Mutable. |
static interface |
JSONContext.Generator
A JSON stringifier.
|
static interface |
JSONContext.Parser
A blocking JSON parser.
|
| Modifier and Type | Method and Description |
|---|---|
String |
generate(List<T> messages)
Converts a list of messages to a JSON string.
|
String |
generate(T message)
Converts a single message to a JSON string.
|
JSONContext.Generator |
getGenerator() |
JSONContext.Parser |
getParser() |
default JSONContext.AsyncParser |
newAsyncParser() |
T[] |
parse(InputStream stream)
Deprecated.
use
parse(Reader) instead |
T[] |
parse(Reader reader)
Parses an array of messages from the given reader.
|
T[] |
parse(String json)
Parses an array of messages from the given string.
|
@Deprecated T[] parse(InputStream stream) throws ParseException
parse(Reader) insteadParses an array of messages from the given stream.
stream - the stream to parse fromParseException - in case of parsing errorsT[] parse(Reader reader) throws ParseException
Parses an array of messages from the given reader.
reader - the reader to parse fromParseException - in case of parsing errorsT[] parse(String json) throws ParseException
Parses an array of messages from the given string.
json - the JSON string to parse fromParseException - in case of parsing errorsdefault JSONContext.AsyncParser newAsyncParser()
JSONContext.AsyncParser instance, or null if non-blocking parsing is not supportedString generate(T message)
Converts a single message to a JSON string.
message - the message to stringifyString generate(List<T> messages)
Converts a list of messages to a JSON string.
messages - the list of messages to stringifyJSONContext.Parser getParser()
JSONContext.Generator getGenerator()
Copyright © 2008–2023 The CometD Project. All rights reserved.