Package com.google.protobuf.util
Class JsonFormat
- java.lang.Object
-
- com.google.protobuf.util.JsonFormat
-
public class JsonFormat extends java.lang.Object
Utility class to convert protobuf messages to/from the Proto3 JSON format. Only proto3 features are supported. Proto2 only features such as extensions and unknown fields are discarded in the conversion. That is, when converting proto2 messages to JSON format, extensions and unknown fields are treated as if they do not exist. This applies to proto2 messages embedded in proto3 messages as well.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
JsonFormat.CompactTextGenerator
Format the JSON without indentationstatic class
JsonFormat.Parser
A Parser parses the proto3 JSON format into a protobuf message.private static class
JsonFormat.ParserImpl
private static class
JsonFormat.PrettyTextGenerator
A TextGenerator adds indentation when writing formatted text.static class
JsonFormat.Printer
A Printer converts a protobuf message to the proto3 JSON format.private static class
JsonFormat.PrinterImpl
A Printer converts protobuf messages to the proto3 JSON format.(package private) static interface
JsonFormat.TextGenerator
An interface for JSON formatting that can be used in combination with the omittingInsignificantWhitespace() method.static class
JsonFormat.TypeRegistry
A TypeRegistry is used to resolve Any messages in the JSON conversion.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Logger
logger
-
Constructor Summary
Constructors Modifier Constructor Description private
JsonFormat()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
getTypeName(java.lang.String typeUrl)
static JsonFormat.Parser
parser()
Creates aJsonFormat.Parser
with default configuration.static JsonFormat.Printer
printer()
Creates aJsonFormat.Printer
with default configurations.private static java.lang.String
unsignedToString(int value)
Convert an unsigned 32-bit integer to a string.private static java.lang.String
unsignedToString(long value)
Convert an unsigned 64-bit integer to a string.
-
-
-
Method Detail
-
printer
public static JsonFormat.Printer printer()
Creates aJsonFormat.Printer
with default configurations.
-
parser
public static JsonFormat.Parser parser()
Creates aJsonFormat.Parser
with default configuration.
-
unsignedToString
private static java.lang.String unsignedToString(int value)
Convert an unsigned 32-bit integer to a string.
-
unsignedToString
private static java.lang.String unsignedToString(long value)
Convert an unsigned 64-bit integer to a string.
-
getTypeName
private static java.lang.String getTypeName(java.lang.String typeUrl) throws InvalidProtocolBufferException
- Throws:
InvalidProtocolBufferException
-
-