public class JSONWire extends TextWire
This class provides functionality for managing JSON data in a wire format.
It currently provides a subset of functionalities similar to the YAML wire format.
The core capability of this class is to handle JSON data structures as Bytes
objects, allowing for efficient manipulation and parsing.
TextWire.TextValueInWireIn.HeaderTypeWireOut.EndOfWire| Modifier and Type | Field and Description |
|---|---|
static @NotNull net.openhft.chronicle.bytes.Bytes<byte[]> |
ULL
Deprecated.
|
BINARY, lineStart, readContext, TYPE_STR, valueIn, writeContextsb, TYPE, valueOutbytes, classLookup, commentListener, DEFAULT_USE_PADDING, parent, use8bitMARSHALLABLE_IN_INTERN_SIZE| Constructor and Description |
|---|
JSONWire()
Default constructor, initializes with elastic bytes allocated on heap.
|
JSONWire(@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes)
Constructs a JSONWire with the given bytes.
|
JSONWire(@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes,
boolean use8bit)
Constructs a JSONWire with the given bytes and a flag for using 8-bit.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
asText(@NotNull Wire wire)
Converts the content of the provided wire to a JSON string.
|
void |
copyOne(@NotNull WireOut wire,
boolean expectKeyValues,
boolean topLevel)
Copies one segment of data from this wire to the given wire output.
|
void |
copyTo(@NotNull WireOut wire)
Copies the content from the current WireIn source to the provided WireOut destination.
|
protected @NotNull TextWire.TextValueIn |
createValueIn()
Creates and returns a new instance of TextValueIn.
|
protected @NotNull net.openhft.chronicle.wire.JSONWire.JSONValueOut |
createValueOut()
Creates and returns a new instance of
YamlValueOut. |
protected Class<?> |
defaultKeyClass()
Returns the default class to be used as a key.
|
protected void |
escape0(@NotNull CharSequence s,
@NotNull net.openhft.chronicle.wire.Quotes quotes)
Escapes special characters in a CharSequence as per JSON String encoding standards detailed in RFC 7159, Section 7.
|
static @NotNull JSONWire |
from(@NotNull String text)
Static method to construct a JSONWire from a string representation of JSON.
|
protected @NotNull net.openhft.chronicle.bytes.StopCharsTester |
getStrictEscapingEndOfText()
Retrieves the StopCharsTester that determines the end of text with strict escaping.
|
protected @NotNull net.openhft.chronicle.wire.Quotes |
needsQuotes(@NotNull CharSequence s)
Determines the type of quotes (if any) required for the given CharSequence
s based on the YAML format's escaping requirements. |
protected @NotNull StringBuilder |
readField(@NotNull StringBuilder sb)
Reads the field from the current position of the wire and appends it to the given StringBuilder.
|
@NotNull TextWire |
useTextDocuments()
Configures this TextWire instance to use textual document contexts for reading and writing.
|
boolean |
useTypes()
Gets the current setting for the use of types during JSON parsing.
|
JSONWire |
useTypes(boolean outputTypes)
Sets the flag to determine whether to use types during the JSON parsing or not.
|
ValueOut |
writeEvent(Class<?> expectedType,
Object eventKey)
Writes an event to the stream based on the type and event key.
|
void |
writeStartEvent()
Start an event object, mostly for internal use.
|
acquireWritingDocument, classLookup, classLookup, clear, consumeDocumentStart, consumePadding, consumePadding, consumeWhiteSpace, fromFile, getEscapingEndEventName, getEscapingEndOfText, getEscapingQuotes, getValueIn, hasMetaDataPrefix, initReadContext, isBinary, load, methodReaderBuilder, methodWriter, methodWriterBuilder, newBooleanReference, newIntArrayReference, newIntReference, newLongArrayReference, newLongReference, parseUntil, parseUntil, parseWord, peekStringIgnoreCase, read, read, read, read2, readCode, readComment, readEvent, readEventNumber, readingDocument, readingDocument, readingPeekYaml, readObject, reset, rollbackIfNotComplete, strict, strict, toString, unescape, useBinaryDocuments, useSelfDescribingMessage, writingDocument, writingIsCompleteacquireStringBuilder, addPadding, addTimeStamps, addTimeStamps, append, append, appendU4, bytes, dropDefault, getValueOut, trimFirstCurly, trimFirstCurly, write, write, write, writeComment, writeEndEvent, writeObjectbytesComment, commentListener, endOfWire, enterHeader, forceNotInsideHeader, headerNumber, headerNumber, headNumberCheck, isInsideHeader, notCompleteIsNotPresent, notCompleteIsNotPresent, objectInput, objectOutput, parent, parent, pauser, pauser, readAndSetLength, readDataHeader, readFirstHeader, readFirstHeader, readMetaDataHeader, updateFirstHeader, updateFirstHeader, updateHeader, usePadding, usePadding, writeEndOfWire, writeFirstHeaderclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitnewYamlWireOnHeapendEvent, hasMore, hintReadInputOrder, isEmpty, isEndEvent, isNotEmptyAfterPadding, rawReadData, read, readAlignTo, readAllAsMap, readDataHeader, readDocument, readDocument, readEventName, startEventmethodReader, readBytes, readBytes, readDocument, readMap, readText, readTextpadToCacheAlign, writeAlignTo, writeAllAsMap, writeDocument, writeEventId, writeEventId, writeEventName, writeEventName, writeNotCompleteDocument, writingDocumentnewTwoLongReferencebuilder, methodWriterBuilder, recordHistory, writeBytes, writeDocument, writeDocument, writeMap, writeMessage, writeMessage, writeText@Deprecated @NotNull public static final @NotNull net.openhft.chronicle.bytes.Bytes<byte[]> ULL
public JSONWire()
public JSONWire(@NotNull
@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes,
boolean use8bit)
bytes - The bytes to be used for initializing.use8bit - Flag indicating whether to use 8-bit representation.public JSONWire(@NotNull
@NotNull net.openhft.chronicle.bytes.Bytes<?> bytes)
bytes - The bytes to be used for initializing.@NotNull public static @NotNull JSONWire from(@NotNull @NotNull String text)
text - The string containing JSON data.public static String asText(@NotNull @NotNull Wire wire) throws net.openhft.chronicle.core.io.InvalidMarshallableException
wire - The wire instance to be converted.net.openhft.chronicle.core.io.InvalidMarshallableException - If there's an error during conversion.protected Class<?> defaultKeyClass()
TextWiredefaultKeyClass in class TextWireObject.public JSONWire useTypes(boolean outputTypes)
This method is designed to follow the builder pattern, allowing it to be chained with other method calls on the JSONWire object.
outputTypes - A boolean value indicating whether to use types.JSONWire class.public boolean useTypes()
true if types are being used in the current instance, otherwise false.@NotNull public @NotNull TextWire useTextDocuments()
TextWireuseTextDocuments in class TextWire@NotNull protected @NotNull net.openhft.chronicle.wire.JSONWire.JSONValueOut createValueOut()
YamlWireOutYamlValueOut.createValueOut in class YamlWireOut<TextWire>@NotNull protected @NotNull TextWire.TextValueIn createValueIn()
TextWirecreateValueIn in class TextWirepublic void copyTo(@NotNull
@NotNull WireOut wire)
throws net.openhft.chronicle.core.io.InvalidMarshallableException
WireInpublic void copyOne(@NotNull
@NotNull WireOut wire,
boolean expectKeyValues,
boolean topLevel)
throws net.openhft.chronicle.core.io.InvalidMarshallableException
wire - The wire output to copy the data to.expectKeyValues - Flag indicating if the current position is inside a map structure.topLevel - Flag indicating if this is the topmost level of the copy operation.net.openhft.chronicle.core.io.InvalidMarshallableException - if there's a problem with copying the data.@NotNull
protected @NotNull net.openhft.chronicle.wire.Quotes needsQuotes(@NotNull
@NotNull CharSequence s)
YamlWireOuts based on the YAML format's escaping requirements.
This method decides between using no quotes, single quotes, or double quotes.needsQuotes in class YamlWireOut<TextWire>s - The CharSequence to be analyzed.protected void escape0(@NotNull
@NotNull CharSequence s,
@NotNull
@NotNull net.openhft.chronicle.wire.Quotes quotes)
escape0 in class YamlWireOut<TextWire>s - The CharSequence to escape.quotes - Specifies the type of quotes used in the CharSequence and guides escaping.public ValueOut writeEvent(Class<?> expectedType, Object eventKey) throws net.openhft.chronicle.core.io.InvalidMarshallableException
WireOutwriteEvent in interface WireOutwriteEvent in class YamlWireOut<TextWire>expectedType - The expected type of the event to write.eventKey - The key of the event.net.openhft.chronicle.core.io.InvalidMarshallableException - if there's an error marshalling the event.public void writeStartEvent()
WireOutwriteStartEvent in interface WireOutwriteStartEvent in class YamlWireOut<TextWire>@NotNull protected @NotNull StringBuilder readField(@NotNull @NotNull StringBuilder sb)
TextWire@NotNull protected @NotNull net.openhft.chronicle.bytes.StopCharsTester getStrictEscapingEndOfText()
TextWiregetStrictEscapingEndOfText in class TextWireCopyright © 2024. All rights reserved.