Top Description Inners Fields Constructors Methods
com.google.protobuf.util

public Class JsonFormat

extends Object
Class Inheritance
Imports
com.google.common.base.Preconditions, com.google.common.io.BaseEncoding, com.google.errorprone.annotations.CanIgnoreReturnValue, com.google.gson.Gson, .GsonBuilder, .JsonArray, .JsonElement, .JsonIOException, .JsonNull, .JsonObject, .JsonParser, .JsonPrimitive, com.google.gson.stream.JsonReader, com.google.protobuf.Any, .BoolValue, .ByteString, .BytesValue, .Descriptors.Descriptor, .Descriptors.EnumDescriptor, .Descriptors.EnumValueDescriptor, .Descriptors.FieldDescriptor, .Descriptors.FieldDescriptor.Type, .Descriptors.FileDescriptor, .Descriptors.OneofDescriptor, .DoubleValue, .Duration, .DynamicMessage, .FieldMask, .FloatValue, .Int32Value, .Int64Value, .InvalidProtocolBufferException, .ListValue, .Message, .MessageOrBuilder, .NullValue, .StringValue, .Struct, .Timestamp, .UInt32Value, .UInt64Value, .Value, java.io.IOException, .Reader, .StringReader, java.math.BigDecimal, .BigInteger, java.text.ParseException, java.util.Collection, .Collections, .Comparator, .HashMap, .HashSet, .List, .Map, .Set, .TreeMap, java.util.logging.Logger

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 and Inner Type Summary

Modifier and TypeClass and Description
private static class
JsonFormat.CompactTextGenerator

Format the json without indentation

public static class
JsonFormat.Parser

A Parser parses JSON to protobuf message.

private static class
private static class
JsonFormat.PrettyTextGenerator

A TextGenerator adds indentation when writing formatted text.

public static class
JsonFormat.Printer

A Printer converts protobuf message to JSON format.

private static class
JsonFormat.PrinterImpl

A Printer converts protobuf messages to JSON format.

pack-priv static interface
JsonFormat.TextGenerator

An interface for json formatting that can be used in combination with the omittingInsignificantWhitespace() method

public static class
JsonFormat.TypeRegistry

A TypeRegistry is used to resolve Any messages in the JSON conversion.

Field Summary

Modifier and TypeField and Description
private static final Logger

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static String
public static JsonFormat.Parser
parser()

Creates a Parser with default configuration.

public static JsonFormat.Printer
printer()

Creates a Printer with default configurations.

private static String
unsignedToString(final int value)

Convert an unsigned 32-bit integer to a string.

private static String
unsignedToString(final long value)

Convert an unsigned 64-bit integer to a string.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait