Package com.google.protobuf.util
Class JsonFormat
java.lang.Object
com.google.protobuf.util.JsonFormat
Utility classes to convert protobuf messages to/from JSON format. The JSON
format follows Proto3 JSON specification and only proto3 features are
supported. Proto2 only features (e.g., extensions and unknown fields) will
be discarded in the conversion. That is, when converting proto2 messages
to JSON format, extensions and unknown fields will be treated as if they
do not exist. This applies to proto2 messages embedded in proto3 messages
as well.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Format the json without indentationstatic class
A Parser parses JSON to protobuf message.private static class
private static final class
A TextGenerator adds indentation when writing formatted text.static class
A Printer converts protobuf message to JSON format.private static final class
A Printer converts protobuf messages to JSON format.(package private) static interface
An interface for json formatting that can be used in combination with the omittingInsignificantWhitespace() methodstatic class
A TypeRegistry is used to resolve Any messages in the JSON conversion. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
getTypeName
(String typeUrl) static JsonFormat.Parser
parser()
Creates aJsonFormat.Parser
with default configuration.static JsonFormat.Printer
printer()
Creates aJsonFormat.Printer
with default configurations.private static String
unsignedToString
(int value) Convert an unsigned 32-bit integer to a string.private static String
unsignedToString
(long value) Convert an unsigned 64-bit integer to a string.
-
Field Details
-
logger
-
-
Constructor Details
-
JsonFormat
private JsonFormat()
-
-
Method Details
-
printer
Creates aJsonFormat.Printer
with default configurations. -
parser
Creates aJsonFormat.Parser
with default configuration. -
unsignedToString
Convert an unsigned 32-bit integer to a string. -
unsignedToString
Convert an unsigned 64-bit integer to a string. -
getTypeName
- Throws:
InvalidProtocolBufferException
-