Package com.google.protobuf.util
Class JsonFormat.Parser
- java.lang.Object
-
- com.google.protobuf.util.JsonFormat.Parser
-
- Enclosing class:
- JsonFormat
public static class JsonFormat.Parser extends java.lang.Object
A Parser parses JSON to protobuf message.
-
-
Field Summary
Fields Modifier and Type Field Description private static int
DEFAULT_RECURSION_LIMIT
private boolean
ignoringUnknownFields
private JsonFormat.TypeRegistry
oldRegistry
private int
recursionLimit
private TypeRegistry
registry
-
Constructor Summary
Constructors Modifier Constructor Description private
Parser(TypeRegistry registry, JsonFormat.TypeRegistry oldRegistry, boolean ignoreUnknownFields, int recursionLimit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonFormat.Parser
ignoringUnknownFields()
Creates a newJsonFormat.Parser
configured to not throw an exception when an unknown field is encountered.void
merge(java.io.Reader json, Message.Builder builder)
Parses from JSON into a protobuf message.void
merge(java.lang.String json, Message.Builder builder)
Parses from JSON into a protobuf message.(package private) JsonFormat.Parser
usingRecursionLimit(int recursionLimit)
JsonFormat.Parser
usingTypeRegistry(TypeRegistry registry)
Creates a newJsonFormat.Parser
using the given registry.JsonFormat.Parser
usingTypeRegistry(JsonFormat.TypeRegistry oldRegistry)
Creates a newJsonFormat.Parser
using the given registry.
-
-
-
Field Detail
-
registry
private final TypeRegistry registry
-
oldRegistry
private final JsonFormat.TypeRegistry oldRegistry
-
ignoringUnknownFields
private final boolean ignoringUnknownFields
-
recursionLimit
private final int recursionLimit
-
DEFAULT_RECURSION_LIMIT
private static final int DEFAULT_RECURSION_LIMIT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Parser
private Parser(TypeRegistry registry, JsonFormat.TypeRegistry oldRegistry, boolean ignoreUnknownFields, int recursionLimit)
-
-
Method Detail
-
usingTypeRegistry
public JsonFormat.Parser usingTypeRegistry(JsonFormat.TypeRegistry oldRegistry)
Creates a newJsonFormat.Parser
using the given registry. The new Parser clones all other configurations from this Parser.- Throws:
java.lang.IllegalArgumentException
- if a registry is already set.
-
usingTypeRegistry
public JsonFormat.Parser usingTypeRegistry(TypeRegistry registry)
Creates a newJsonFormat.Parser
using the given registry. The new Parser clones all other configurations from this Parser.- Throws:
java.lang.IllegalArgumentException
- if a registry is already set.
-
ignoringUnknownFields
public JsonFormat.Parser 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
public void merge(java.lang.String json, Message.Builder builder) throws InvalidProtocolBufferException
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
public void merge(java.io.Reader json, Message.Builder builder) throws java.io.IOException
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.java.io.IOException
- if reading from the input throws.
-
usingRecursionLimit
JsonFormat.Parser usingRecursionLimit(int recursionLimit)
-
-