Enum Collection Parse Help

beantownace

Active member
Joined
Feb 15, 2019
Messages
41
Programming Experience
5-10
Hello all,

I need some intel and hoping someone may be able to help where I have some strings coming in via JSON this may be easy and not thinking about it right. I have a single enum that I am parsing fine where I do a:
C#:
Enum.Parse<CustomerGroup>("GroupA") //GroupA coming in a string via JSON this works well.
I then have a collection of enums where I am having some trouble how to parse it with strings with this Google Protobuf Collection. Here is what it has now without the strings.
C#:
Google.Protobuf.Collections.RepeatedField<CustomerOperation> customerOperations = { CustomerOperation.CreateCustomer, CustomerOperation.CreateCustomerGroup };
I need to pass this with strings so the enum values are as follows:
C#:
CustomerOperation.CreateCustomer = "CREATE_CUSTOMER"
CustomerOperation.CreateCustomerGroup = "CREATE_CUSTOMER_GROUP"
Any idea how to send this via JSON value it would be key "customerOperations" : [something here]
and how I can parse that to the enum collection.

Thanks all really appreciate any help hope this makes sense.
 
Last edited by a moderator:
My understanding is that the Google.Protobuf.Collections.RepeatedField is effectively just a representation of an array.

Are you trying to parse back into a Google.Protobuf.Collections.RepeatedField field, or just any array or list like what would normally by parsed?
 
Back
Top Bottom