Package com.google.protobuf.util
Class JsonFormat.Parser
java.lang.Object
com.google.protobuf.util.JsonFormat.Parser
- Enclosing class:
JsonFormat
A Parser parses JSON to protobuf message.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private final boolean
private final JsonFormat.TypeRegistry
private final int
private final TypeRegistry
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Parser
(TypeRegistry registry, JsonFormat.TypeRegistry oldRegistry, boolean ignoreUnknownFields, int recursionLimit) -
Method Summary
Modifier and TypeMethodDescriptionCreates a newJsonFormat.Parser
configured to not throw an exception when an unknown field is encountered.void
merge
(Reader json, Message.Builder builder) Parses from JSON into a protobuf message.void
merge
(String json, Message.Builder builder) Parses from JSON into a protobuf message.(package private) JsonFormat.Parser
usingRecursionLimit
(int recursionLimit) usingTypeRegistry
(TypeRegistry registry) Creates a newJsonFormat.Parser
using the given registry.usingTypeRegistry
(JsonFormat.TypeRegistry oldRegistry) Creates a newJsonFormat.Parser
using the given registry.
-
Field Details
-
registry
-
oldRegistry
-
ignoringUnknownFields
private final boolean ignoringUnknownFields -
recursionLimit
private final int recursionLimit -
DEFAULT_RECURSION_LIMIT
private static final int DEFAULT_RECURSION_LIMIT- See Also:
-
-
Constructor Details
-
Parser
private Parser(TypeRegistry registry, JsonFormat.TypeRegistry oldRegistry, boolean ignoreUnknownFields, int recursionLimit)
-
-
Method Details
-
usingTypeRegistry
Creates a newJsonFormat.Parser
using the given registry. The new Parser clones all other configurations from this Parser.- Throws:
IllegalArgumentException
- if a registry is already set.
-
usingTypeRegistry
Creates a newJsonFormat.Parser
using the given registry. The new Parser clones all other configurations from this Parser.- Throws:
IllegalArgumentException
- if a registry is already set.
-
ignoringUnknownFields
Creates a newJsonFormat.Parser
configured to not throw an exception when an unknown field is encountered. The new Parser clones all other configurations from this Parser. -
merge
Parses from JSON into a protobuf message.- Throws:
InvalidProtocolBufferException
- if the input is not valid JSON format or there are unknown fields in the input.
-
merge
Parses from JSON into a protobuf message.- Throws:
InvalidProtocolBufferException
- if the input is not valid JSON format or there are unknown fields in the input.IOException
- if reading from the input throws.
-
usingRecursionLimit
-