|
|
|
@ -51,6 +51,7 @@ import com.google.protobuf.Descriptors.Descriptor; |
|
|
|
|
import com.google.protobuf.Descriptors.EnumDescriptor; |
|
|
|
|
import com.google.protobuf.Descriptors.EnumValueDescriptor; |
|
|
|
|
import com.google.protobuf.Descriptors.FieldDescriptor; |
|
|
|
|
import com.google.protobuf.Descriptors.FieldDescriptor.Type; |
|
|
|
|
import com.google.protobuf.Descriptors.FileDescriptor; |
|
|
|
|
import com.google.protobuf.Descriptors.OneofDescriptor; |
|
|
|
|
import com.google.protobuf.DoubleValue; |
|
|
|
@ -965,16 +966,7 @@ public class JsonFormat { |
|
|
|
|
throw new InvalidProtocolBufferException("Invalid Value type."); |
|
|
|
|
} |
|
|
|
|
for (Map.Entry<FieldDescriptor, Object> entry : fields.entrySet()) { |
|
|
|
|
FieldDescriptor field = entry.getKey(); |
|
|
|
|
if (field.getType() == FieldDescriptor.Type.DOUBLE) { |
|
|
|
|
Double doubleValue = (Double) entry.getValue(); |
|
|
|
|
if (doubleValue.isNaN() || doubleValue.isInfinite()) { |
|
|
|
|
throw new IllegalArgumentException( |
|
|
|
|
"google.protobuf.Value cannot encode double values for " |
|
|
|
|
+ "infinity or nan, because they would be parsed as a string."); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
printSingleFieldValue(field, entry.getValue()); |
|
|
|
|
printSingleFieldValue(entry.getKey(), entry.getValue()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1691,7 +1683,7 @@ public class JsonFormat { |
|
|
|
|
Object key = parseFieldValue(keyField, new JsonPrimitive(entry.getKey()), entryBuilder); |
|
|
|
|
Object value = parseFieldValue(valueField, entry.getValue(), entryBuilder); |
|
|
|
|
if (value == null) { |
|
|
|
|
if (ignoringUnknownFields && valueField.getType() == FieldDescriptor.Type.ENUM) { |
|
|
|
|
if (ignoringUnknownFields && valueField.getType() == Type.ENUM) { |
|
|
|
|
continue; |
|
|
|
|
} else { |
|
|
|
|
throw new InvalidProtocolBufferException("Map value cannot be null."); |
|
|
|
@ -1732,7 +1724,7 @@ public class JsonFormat { |
|
|
|
|
for (int i = 0; i < array.size(); ++i) { |
|
|
|
|
Object value = parseFieldValue(field, array.get(i), builder); |
|
|
|
|
if (value == null) { |
|
|
|
|
if (ignoringUnknownFields && field.getType() == FieldDescriptor.Type.ENUM) { |
|
|
|
|
if (ignoringUnknownFields && field.getType() == Type.ENUM) { |
|
|
|
|
continue; |
|
|
|
|
} else { |
|
|
|
|
throw new InvalidProtocolBufferException( |
|
|
|
|