alexeyxo / protobuf-swift

Google ProtocolBuffers for Apple Swift
http://protobuf.io/#swift
Apache License 2.0
938 stars 138 forks source link

int64 transformed to string for .encode() #201

Closed cd24 closed 7 years ago

cd24 commented 7 years ago

Version of protoc (protoc --version)

3.1

Version of ProtocolBuffers.framework

3.0.6

.proto file to reproduce

syntax = "proto3";
message myMessage {
  int64 my_int = 1;
}

Description

When using this tool, I expect for int64 fields to be represented as numbers in their json form (int64). In the same way that the component casts Double, I would expect that a declared Int64 field is cast as Int64, rather than wrapped in a string.

The produced file has

jsonMap["myInt"] = "\(myInt)"

When i would expect

jsonMap["myInt"] = myInt

I have confirmed that removing the quotes in the generated file does not produce errors for encoding, and creates the expected behavior.

alexeyxo commented 7 years ago

Hi! You are wrong. In official google specification Int64/Fixed64/UInt64 in json has represented as String. JSON Mapping