Skip to content

[Question] Use RawValue enum when formatting to JSON #252

@gregoireLem

Description

@gregoireLem

Description

Version of protoc (protoc --version)

libprotoc 3.6.1

Version of ProtocolBuffers.framework

Protobuf-swift version: 4.0

Description

Here is an enum in my proto file

enum battery_status {
STARTED = 0;
STOPED = 1;
ABSENT = 2;
}

To send it back in JSON, I use battery_status.encode()

I get :

["status": "ABSENT"]

Is there a way that the dictionary outputted uses raw value ?

What I want is to get :

["status":2]

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions