Skip to content

Decoding OptionSets #416

Description

@jshier

I'm attempting to parse an API that uses arrays of strings to represent an option's various settings. It seems natural to try and parse this as a type conforming to OptionSet. However, the disconnect between the rawValue and the strings in the array may be a bit too much.

I'm parsing something like this:

{
  "notification_options": ["phone", "email"]
}

Any ideas here? I'm currently going down the path of creating a failable, string-based initializer for my OptionSet but I don't think it's going to be very elegant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions