public final class DebugStringUtil
extends java.lang.Object
Note that zserio objects must be generated with -withTypeInfoCode
zserio option to enable
JSON debug string!
Constructor and Description |
---|
DebugStringUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
fromJsonFile(java.lang.Class<?> zserioClass,
java.lang.String fileName,
java.lang.Object... arguments)
Parses JSON debug file and creates instance of the requested zserio object.
|
static java.lang.Object |
fromJsonFile(TypeInfo typeInfo,
java.lang.String fileName,
java.lang.Object... arguments)
Parses JSON debug file and creates instance of the requested zserio object.
|
static java.lang.Object |
fromJsonStream(java.lang.Class<?> zserioClass,
java.io.Reader reader,
java.lang.Object... arguments)
Parses JSON debug string from given text stream and creates instance of the requested zserio object.
|
static java.lang.Object |
fromJsonStream(TypeInfo typeInfo,
java.io.Reader reader,
java.lang.Object... arguments)
Parses JSON debug string from given text stream and creates instance of the requested zserio object.
|
static java.lang.Object |
fromJsonString(java.lang.Class<?> zserioClass,
java.lang.String jsonString,
java.lang.Object... arguments)
Parses JSON debug string and creates instance of the requested zserio object.
|
static java.lang.Object |
fromJsonString(TypeInfo typeInfo,
java.lang.String jsonString,
java.lang.Object... arguments)
Parses JSON debug string and creates instance of the requested zserio object.
|
static void |
toJsonFile(java.lang.Object zserioObject,
java.lang.String fileName)
Writes contents of given zserio object to debug file in JSON format using Walker with JsonWriter.
|
static void |
toJsonFile(java.lang.Object zserioObject,
java.lang.String fileName,
int indent)
Writes contents of given zserio object to debug file in JSON format using Walker with JsonWriter.
|
static void |
toJsonFile(java.lang.Object zserioObject,
java.lang.String fileName,
int indent,
WalkFilter walkFilter)
Writes contents of given zserio object to debug file in JSON format using Walker with JsonWriter.
|
static void |
toJsonFile(java.lang.Object zserioObject,
java.lang.String fileName,
WalkFilter walkFilter)
Writes contents of given zserio object to debug file in JSON format using Walker with JsonWriter.
|
static void |
toJsonStream(java.lang.Object zserioObject,
java.io.Writer writer)
Writes contents of given zserio object to debug stream in JSON format using Walker with JsonWriter.
|
static void |
toJsonStream(java.lang.Object zserioObject,
java.io.Writer writer,
int indent)
Writes contents of given zserio object to debug stream in JSON format using Walker with JsonWriter.
|
static void |
toJsonStream(java.lang.Object zserioObject,
java.io.Writer writer,
int indent,
WalkFilter walkFilter)
Writes contents of given zserio object to debug stream in JSON format using Walker with JsonWriter.
|
static void |
toJsonStream(java.lang.Object zserioObject,
java.io.Writer writer,
WalkFilter walkFilter)
Writes contents of given zserio object to debug stream in JSON format using Walker with JsonWriter.
|
static java.lang.String |
toJsonString(java.lang.Object zserioObject)
Gets debug string in JSON format using Walker with JsonWriter for given zserio object.
|
static java.lang.String |
toJsonString(java.lang.Object zserioObject,
int indent)
Gets debug string in JSON format using Walker with JsonWriter for given zserio object.
|
static java.lang.String |
toJsonString(java.lang.Object zserioObject,
int indent,
WalkFilter walkFilter)
Gets debug string in JSON format using Walker with JsonWriter for given zserio object.
|
static java.lang.String |
toJsonString(java.lang.Object zserioObject,
WalkFilter walkFilter)
Gets debug string in JSON format using Walker with JsonWriter for given zserio object.
|
public static void toJsonStream(java.lang.Object zserioObject, java.io.Writer writer, int indent, WalkFilter walkFilter)
This function allows setting of indentation of JSON output together with the walk filter.
Example:
import java.io.StringWriter; import zserio.runtime.DebugStringUtil; import zserio.runtime.walker.ArrayLengthWalkFilter; final StringWriter writer = new StringWriter(); final SomeZserioObject zserioObject = new SomeZserioObject(); final int indent = 4; final ArrayLengthWalkFilter walkFilter = new ArrayLengthWalkFilter(5); DebugStringUtil.toJsonStream(zserioObject, writer, indent, walkFilter);
zserioObject
- Zserio object to use.writer
- Writer to use.indent
- Indent argument for JsonWriter.walkFilter
- WalkFilter to use by Walker.public static void toJsonStream(java.lang.Object zserioObject, java.io.Writer writer, int indent)
This function allows setting of indentation of JSON output.
Example:
import java.io.StringWriter; import zserio.runtime.DebugStringUtil; final StringWriter writer = new StringWriter(); final SomeZserioObject zserioObject = new SomeZserioObject(); final int indent = 4; DebugStringUtil.toJsonStream(zserioObject, writer, indent);
zserioObject
- Zserio object to use.writer
- Writer to use.indent
- Indent argument for JsonWriter.public static void toJsonStream(java.lang.Object zserioObject, java.io.Writer writer, WalkFilter walkFilter)
This function allows setting of the walk filter.
The following example shows filtering of arrays up to 5 elements:
import java.io.StringWriter; import zserio.runtime.DebugStringUtil; import zserio.runtime.walker.ArrayLengthWalkFilter; final StringWriter writer = new StringWriter(); final SomeZserioObject zserioObject = new SomeZserioObject(); final ArrayLengthWalkFilter walkFilter = new ArrayLengthWalkFilter(5); DebugStringUtil.toJsonStream(zserioObject, writer, walkFilter);
zserioObject
- Zserio object to use.writer
- Writer to use.walkFilter
- WalkFilter to use by Walker.public static void toJsonStream(java.lang.Object zserioObject, java.io.Writer writer)
Example:
import java.io.StringWriter; import zserio.runtime.DebugStringUtil; final StringWriter writer = new StringWriter(); final SomeZserioObject zserioObject = new SomeZserioObject(); DebugStringUtil.toJsonStream(zserioObject, writer);
zserioObject
- Zserio object to use.writer
- Writer to use.public static java.lang.String toJsonString(java.lang.Object zserioObject, int indent, WalkFilter walkFilter)
This function allows setting of indentation of JSON output together with the walk filter.
Example:
import zserio.runtime.DebugStringUtil; import zserio.runtime.walker.ArrayLengthWalkFilter; final SomeZserioObject zserioObject = new SomeZserioObject(); final int indent = 4; final ArrayLengthWalkFilter walkFilter = new ArrayLengthWalkFilter(5); System.out.println(DebugStringUtil.toJsonString(zserioObject, indent, walkFilter));
zserioObject
- Zserio object to use.indent
- Indent argument for JsonWriter.walkFilter
- WalkFilter to use by Walker.public static java.lang.String toJsonString(java.lang.Object zserioObject, int indent)
This function allows setting of indentation of JSON output.
Example:
import zserio.runtime.DebugStringUtil; final SomeZserioObject zserioObject = new SomeZserioObject(); final int indent = 4; System.out.println(DebugStringUtil.toJsonString(zserioObject, indent));
zserioObject
- Zserio object to use.indent
- Indent argument for JsonWriter.public static java.lang.String toJsonString(java.lang.Object zserioObject, WalkFilter walkFilter)
This function allows setting of the walk filter.
The following example shows filtering of arrays up to 5 elements:
import zserio.runtime.DebugStringUtil; import zserio.runtime.walker.ArrayLengthWalkFilter; final SomeZserioObject zserioObject = new SomeZserioObject(); final ArrayLengthWalkFilter walkFilter = new ArrayLengthWalkFilter(5); System.out.println(DebugStringUtil.toJsonString(zserioObject, walkFilter));
zserioObject
- Zserio object to use.walkFilter
- WalkFilter to use by Walker.public static java.lang.String toJsonString(java.lang.Object zserioObject)
Example:
import zserio.runtime.DebugStringUtil; final SomeZserioObject zserioObject = new SomeZserioObject(); System.out.println(DebugStringUtil.toJsonString(zserioObject));
zserioObject
- Zserio object to use.public static void toJsonFile(java.lang.Object zserioObject, java.lang.String fileName, int indent, WalkFilter walkFilter) throws java.io.IOException
This function allows setting of indentation of JSON output together with the walk filter.
Example:
import zserio.runtime.DebugStringUtil; import zserio.runtime.walker.ArrayLengthWalkFilter; final SomeZserioObject zserioObject = new SomeZserioObject(); final int indent = 4; final ArrayLengthWalkFilter walkFilter = new ArrayLengthWalkFilter(5); DebugStringUtil.toJsonFile(zserioObject, "FileName.json", indent, walkFilter);
zserioObject
- Zserio object to use.fileName
- Name of file to write.indent
- Indent argument for JsonWriter.walkFilter
- WalkFilter to use by Walker.java.io.IOException
- When the output file cannot be created correctly.public static void toJsonFile(java.lang.Object zserioObject, java.lang.String fileName, int indent) throws java.io.IOException
This function allows setting of indentation of JSON output.
Example:
import zserio.runtime.DebugStringUtil; final SomeZserioObject zserioObject = new SomeZserioObject(); final int indent = 4; DebugStringUtil.toJsonFile(zserioObject, "FileName.json", indent);
zserioObject
- Zserio object to use.fileName
- Name of file to write.indent
- Indent argument for JsonWriter.java.io.IOException
- When the output file cannot be created correctly.public static void toJsonFile(java.lang.Object zserioObject, java.lang.String fileName, WalkFilter walkFilter) throws java.io.IOException
This function allows setting of the walk filter.
The following example shows filtering of arrays up to 5 elements:
import zserio.runtime.DebugStringUtil; import zserio.runtime.walker.ArrayLengthWalkFilter; final SomeZserioObject zserioObject = new SomeZserioObject(); final ArrayLengthWalkFilter walkFilter = new ArrayLengthWalkFilter(5); DebugStringUtil.toJsonFile(zserioObject, "FileName.json", walkFilter);
zserioObject
- Zserio object to use.fileName
- Name of file to write.walkFilter
- WalkFilter to use by Walker.java.io.IOException
- When the output file cannot be created correctly.public static void toJsonFile(java.lang.Object zserioObject, java.lang.String fileName) throws java.io.IOException
Example:
import zserio.runtime.DebugStringUtil; final SomeZserioObject zserioObject = new SomeZserioObject(); DebugStringUtil.toJsonFile(zserioObject, "FileName.json");
zserioObject
- Zserio object to use.fileName
- Name of file to write.java.io.IOException
- When the output file cannot be created correctly.public static java.lang.Object fromJsonStream(TypeInfo typeInfo, java.io.Reader reader, java.lang.Object... arguments)
The created zserio object is filled according to the data contained in the debug string.
Note that the created object can be only partially initialized depending on the data stored in the JSON debug string.
Example:
import java.io.StringReader; import zserio.runtime.DebugStringUtil; final Reader reader = new StringReader("{}"); final Object zserioObject = DebugStringUtil.fronJsonStream(SomeZserioObject.typeInfo(), reader);
typeInfo
- Type info of the generated zserio object to create.reader
- Text stream to use.arguments
- Arguments of the generated zserio object.public static java.lang.Object fromJsonStream(java.lang.Class<?> zserioClass, java.io.Reader reader, java.lang.Object... arguments)
The created zserio object is filled according to the data contained in the debug string.
Note that the created object can be only partially initialized depending on the data stored in the JSON debug string.
Example:
import java.io.StringReader; import zserio.runtime.DebugStringUtil; final Reader reader = new StringReader("{}"); final Object zserioObject = DebugStringUtil.fronJsonStream(SomeZserioObject.class, reader);
zserioClass
- Class instance of the generated zserio object to create.reader
- Text stream to use.arguments
- Arguments of the generated zserio object.public static java.lang.Object fromJsonString(TypeInfo typeInfo, java.lang.String jsonString, java.lang.Object... arguments)
The created zserio object is filled according to the data contained in the debug string.
Note that the created object can be only partially initialized depending on the data stored in the JSON debug string.
Example:
import zserio.runtime.DebugStringUtil; final Object zserioObject = DebugStringUtil.fronJsonStream(SomeZserioObject.typeInfo(), "{}");
typeInfo
- Type info of the generated zserio object to create.jsonString
- JSON debug string to parse.arguments
- Arguments of the generated zserio object.public static java.lang.Object fromJsonString(java.lang.Class<?> zserioClass, java.lang.String jsonString, java.lang.Object... arguments)
The created zserio object is filled according to the data contained in the debug string.
Note that the created object can be only partially initialized depending on the data stored in the JSON debug string.
Example:
import zserio.runtime.DebugStringUtil; final Object zserioObject = DebugStringUtil.fronJsonStream(SomeZserioObject.class, "{}");
zserioClass
- Class instance of the generated zserio object to create.jsonString
- JSON debug string to parse.arguments
- Arguments of the generated zserio object.public static java.lang.Object fromJsonFile(TypeInfo typeInfo, java.lang.String fileName, java.lang.Object... arguments) throws java.io.FileNotFoundException
The created zserio object is filled according to the data contained in the debug string.
Note that the created object can be only partially initialized depending on the data stored in the JSON debug file.
Example:
import zserio.runtime.DebugStringUtil; final Object zserioObject = DebugStringUtil.fronJsonStream(SomeZserioObject.typeInfo(), "{}");
typeInfo
- Type info of the generated zserio object to create.fileName
- Name of the JSON debug file.arguments
- Arguments of the generated zserio object.java.io.FileNotFoundException
- If given JSON debug file name does not exist.public static java.lang.Object fromJsonFile(java.lang.Class<?> zserioClass, java.lang.String fileName, java.lang.Object... arguments) throws java.io.FileNotFoundException
The created zserio object is filled according to the data contained in the debug string.
Note that the created object can be only partially initialized depending on the data stored in the JSON debug file.
Example:
import zserio.runtime.DebugStringUtil; final Object zserioObject = DebugStringUtil.fronJsonStream(SomeZserioObject.class, "{}");
zserioClass
- Class instance of the generated zserio object to create.fileName
- Name of the JSON debug file.arguments
- Arguments of the generated zserio object.java.io.FileNotFoundException
- If given JSON debug file name does not exist.Last updated 2024-12-05 10:34:50