Package com.google.protobuf.util
Class JsonFormat
- java.lang.Object
-
- com.google.protobuf.util.JsonFormat
-
public class JsonFormat extends java.lang.ObjectUtility 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 Classes Modifier and Type Class Description private static classJsonFormat.CompactTextGeneratorFormat the json without indentationstatic classJsonFormat.ParserA Parser parses JSON to protobuf message.private static classJsonFormat.ParserImplprivate static classJsonFormat.PrettyTextGeneratorA TextGenerator adds indentation when writing formatted text.static classJsonFormat.PrinterA Printer converts protobuf message to JSON format.private static classJsonFormat.PrinterImplA Printer converts protobuf messages to JSON format.(package private) static interfaceJsonFormat.TextGeneratorAn interface for json formatting that can be used in combination with the omittingInsignificantWhitespace() methodstatic classJsonFormat.TypeRegistryA TypeRegistry is used to resolve Any messages in the JSON conversion.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Loggerlogger
-
Constructor Summary
Constructors Modifier Constructor Description privateJsonFormat()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.StringgetTypeName(java.lang.String typeUrl)static JsonFormat.Parserparser()Creates aJsonFormat.Parserwith default configuration.static JsonFormat.Printerprinter()Creates aJsonFormat.Printerwith default configurations.private static java.lang.StringunsignedToString(int value)Convert an unsigned 32-bit integer to a string.private static java.lang.StringunsignedToString(long value)Convert an unsigned 64-bit integer to a string.
-
-
-
Method Detail
-
printer
public static JsonFormat.Printer printer()
Creates aJsonFormat.Printerwith default configurations.
-
parser
public static JsonFormat.Parser parser()
Creates aJsonFormat.Parserwith 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
-
-