Package org.cometd.common
Interface JSONContext<T extends org.cometd.bayeux.Message.Mutable>
- Type Parameters:
T- the type of message
- All Known Subinterfaces:
JSONContext.Client
- All Known Implementing Classes:
JacksonJSONContextClient,JettyJSONContextClient
public interface JSONContext<T extends org.cometd.bayeux.Message.Mutable>
Abstraction for JSON parsing and generation.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA non-blocking JSON parser.static interfaceClient specificJSONContextthat binds toMessage.Mutable.static interfaceA JSON stringifier.static interfaceA blocking JSON parser. -
Method Summary
Modifier and TypeMethodDescriptionConverts a list of messages to a JSON string.Converts a single message to a JSON string.default JSONContext.AsyncParserT[]Parses an array of messages from the given reader.T[]Parses an array of messages from the given string.
-
Method Details
-
parse
Parses an array of messages from the given reader.
- Parameters:
reader- the reader to parse from- Returns:
- an array of messages
- Throws:
ParseException- in case of parsing errors
-
parse
Parses an array of messages from the given string.
- Parameters:
json- the JSON string to parse from- Returns:
- an array of messages
- Throws:
ParseException- in case of parsing errors
-
newAsyncParser
- Returns:
- a new
JSONContext.AsyncParserinstance, or null if non-blocking parsing is not supported
-
generate
Converts a single message to a JSON string.
- Parameters:
message- the message to stringify- Returns:
- the JSON string for the message
-
generate
Converts a list of messages to a JSON string.
- Parameters:
messages- the list of messages to stringify- Returns:
- the JSON string for the messages
-
getParser
JSONContext.Parser getParser()- Returns:
- a synchronous JSON parser to parse any JSON string
-
getGenerator
JSONContext.Generator getGenerator()- Returns:
- a JSON generator to stringify any object to a JSON string
-