proto3-json-serializer
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -44,3 +44,3 @@ "use strict"; | ||
const valueMessage = type.decode(obj.value); | ||
const valueProto3JSON = toproto3json_1.toProto3JSON(valueMessage); | ||
const valueProto3JSON = (0, toproto3json_1.toProto3JSON)(valueMessage); | ||
if (specialJSON.has(typeName)) { | ||
@@ -80,3 +80,3 @@ return { | ||
} | ||
const valueMessage = fromproto3json_1.fromProto3JSON(type, value); | ||
const valueMessage = (0, fromproto3json_1.fromProto3JSON)(type, value); | ||
if (valueMessage === null) { | ||
@@ -83,0 +83,0 @@ return { |
@@ -28,3 +28,3 @@ "use strict"; | ||
function fromProto3JSONToInternalRepresentation(type, json) { | ||
const fullyQualifiedTypeName = typeof type === 'string' ? type : util_1.getFullyQualifiedTypeName(type); | ||
const fullyQualifiedTypeName = typeof type === 'string' ? type : (0, util_1.getFullyQualifiedTypeName)(type); | ||
if (typeof type !== 'string' && 'values' in type) { | ||
@@ -35,3 +35,3 @@ // type is an Enum | ||
} | ||
return enum_1.resolveEnumValueToString(type, json); | ||
return (0, enum_1.resolveEnumValueToString)(type, json); | ||
} | ||
@@ -48,3 +48,3 @@ if (typeof type !== 'string') { | ||
if (fullyQualifiedTypeName === '.google.protobuf.Value') { | ||
return value_1.googleProtobufValueFromProto3JSON(json); | ||
return (0, value_1.googleProtobufValueFromProto3JSON)(json); | ||
} | ||
@@ -55,3 +55,3 @@ if (util_1.wrapperTypes.has(fullyQualifiedTypeName)) { | ||
} | ||
return wrappers_1.wrapperFromProto3JSON(fullyQualifiedTypeName, json); | ||
return (0, wrappers_1.wrapperFromProto3JSON)(fullyQualifiedTypeName, json); | ||
} | ||
@@ -63,3 +63,3 @@ if (json === null) { | ||
if (fullyQualifiedTypeName === '.google.protobuf.Any') { | ||
return any_1.googleProtobufAnyFromProto3JSON(type.root, json); | ||
return (0, any_1.googleProtobufAnyFromProto3JSON)(type.root, json); | ||
} | ||
@@ -73,3 +73,3 @@ if (fullyQualifiedTypeName === '.google.protobuf.Struct') { | ||
} | ||
return value_1.googleProtobufStructFromProto3JSON(json); | ||
return (0, value_1.googleProtobufStructFromProto3JSON)(json); | ||
} | ||
@@ -80,3 +80,3 @@ if (fullyQualifiedTypeName === '.google.protobuf.ListValue') { | ||
} | ||
return value_1.googleProtobufListValueFromProto3JSON(json); | ||
return (0, value_1.googleProtobufListValueFromProto3JSON)(json); | ||
} | ||
@@ -87,3 +87,3 @@ if (fullyQualifiedTypeName === '.google.protobuf.Duration') { | ||
} | ||
return duration_1.googleProtobufDurationFromProto3JSON(json); | ||
return (0, duration_1.googleProtobufDurationFromProto3JSON)(json); | ||
} | ||
@@ -94,3 +94,3 @@ if (fullyQualifiedTypeName === '.google.protobuf.Timestamp') { | ||
} | ||
return timestamp_1.googleProtobufTimestampFromProto3JSON(json); | ||
return (0, timestamp_1.googleProtobufTimestampFromProto3JSON)(json); | ||
} | ||
@@ -101,3 +101,3 @@ if (fullyQualifiedTypeName === '.google.protobuf.FieldMask') { | ||
} | ||
return fieldmask_1.googleProtobufFieldMaskFromProto3JSON(json); | ||
return (0, fieldmask_1.googleProtobufFieldMaskFromProto3JSON)(json); | ||
} | ||
@@ -147,3 +147,3 @@ const result = {}; | ||
} | ||
result[key] = bytes_1.bytesFromProto3JSON(value); | ||
result[key] = (0, bytes_1.bytesFromProto3JSON)(value); | ||
} | ||
@@ -150,0 +150,0 @@ else { |
@@ -36,28 +36,28 @@ "use strict"; | ||
objType.resolveAll(); | ||
const typeName = util_1.getFullyQualifiedTypeName(objType); | ||
const typeName = (0, util_1.getFullyQualifiedTypeName)(objType); | ||
// Types that require special handling according to | ||
// https://developers.google.com/protocol-buffers/docs/proto3#json | ||
if (typeName === '.google.protobuf.Any') { | ||
return any_1.googleProtobufAnyToProto3JSON(obj); | ||
return (0, any_1.googleProtobufAnyToProto3JSON)(obj); | ||
} | ||
if (typeName === '.google.protobuf.Value') { | ||
return value_1.googleProtobufValueToProto3JSON(obj); | ||
return (0, value_1.googleProtobufValueToProto3JSON)(obj); | ||
} | ||
if (typeName === '.google.protobuf.Struct') { | ||
return value_1.googleProtobufStructToProto3JSON(obj); | ||
return (0, value_1.googleProtobufStructToProto3JSON)(obj); | ||
} | ||
if (typeName === '.google.protobuf.ListValue') { | ||
return value_1.googleProtobufListValueToProto3JSON(obj); | ||
return (0, value_1.googleProtobufListValueToProto3JSON)(obj); | ||
} | ||
if (typeName === '.google.protobuf.Duration') { | ||
return duration_1.googleProtobufDurationToProto3JSON(obj); | ||
return (0, duration_1.googleProtobufDurationToProto3JSON)(obj); | ||
} | ||
if (typeName === '.google.protobuf.Timestamp') { | ||
return timestamp_1.googleProtobufTimestampToProto3JSON(obj); | ||
return (0, timestamp_1.googleProtobufTimestampToProto3JSON)(obj); | ||
} | ||
if (typeName === '.google.protobuf.FieldMask') { | ||
return fieldmask_1.googleProtobufFieldMaskToProto3JSON(obj); | ||
return (0, fieldmask_1.googleProtobufFieldMaskToProto3JSON)(obj); | ||
} | ||
if (util_1.wrapperTypes.has(typeName)) { | ||
return wrappers_1.wrapperToProto3JSON(obj); | ||
return (0, wrappers_1.wrapperToProto3JSON)(obj); | ||
} | ||
@@ -69,3 +69,3 @@ const result = {}; | ||
const fieldFullyQualifiedTypeName = fieldResolvedType | ||
? util_1.getFullyQualifiedTypeName(fieldResolvedType) | ||
? (0, util_1.getFullyQualifiedTypeName)(fieldResolvedType) | ||
: null; | ||
@@ -77,2 +77,6 @@ if (value === null) { | ||
if (Array.isArray(value)) { | ||
if (value.length === 0) { | ||
// ignore repeated fields with no values | ||
continue; | ||
} | ||
// if the repeated value has a complex type, convert it to proto3 JSON, otherwise use as is | ||
@@ -102,3 +106,3 @@ result[key] = value.map(fieldResolvedType | ||
if (fieldResolvedType && 'values' in fieldResolvedType && value !== null) { | ||
result[key] = enum_1.resolveEnumValueToString(fieldResolvedType, value); | ||
result[key] = (0, enum_1.resolveEnumValueToString)(fieldResolvedType, value); | ||
continue; | ||
@@ -118,3 +122,3 @@ } | ||
if (Buffer.isBuffer(value) || value instanceof Uint8Array) { | ||
result[key] = bytes_1.bytesToProto3JSON(value); | ||
result[key] = (0, bytes_1.bytesToProto3JSON)(value); | ||
continue; | ||
@@ -121,0 +125,0 @@ } |
@@ -24,3 +24,3 @@ "use strict"; | ||
if (Buffer.isBuffer(obj.value) || obj.value instanceof Uint8Array) { | ||
return bytes_1.bytesToProto3JSON(obj.value); | ||
return (0, bytes_1.bytesToProto3JSON)(obj.value); | ||
} | ||
@@ -45,3 +45,3 @@ if (typeof obj.value === 'object') { | ||
return { | ||
value: bytes_1.bytesFromProto3JSON(json), | ||
value: (0, bytes_1.bytesFromProto3JSON)(json), | ||
}; | ||
@@ -48,0 +48,0 @@ } |
# Changelog | ||
### [0.1.4](https://www.github.com/googleapis/proto3-json-serializer-nodejs/compare/v0.1.3...v0.1.4) (2021-09-20) | ||
### Bug Fixes | ||
* do not emit empty lists to JSON ([#15](https://www.github.com/googleapis/proto3-json-serializer-nodejs/issues/15)) ([af9dfd6](https://www.github.com/googleapis/proto3-json-serializer-nodejs/commit/af9dfd65efb84cfb31af0faca805f53b0ffa9874)) | ||
### [0.1.3](https://www.github.com/googleapis/proto3-json-serializer-nodejs/compare/v0.1.2...v0.1.3) (2021-08-18) | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "proto3-json-serializer", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"repository": "googleapis/proto3-json-serializer-nodejs", | ||
@@ -5,0 +5,0 @@ "description": "Support for proto3 JSON serialiazation/deserialization for protobuf.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77196
910