Skip to content

Instantly share code, notes, and snippets.

@paulcsmith
Created February 12, 2019 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulcsmith/6a2d8596f985baf8bbf692973fef13d9 to your computer and use it in GitHub Desktop.
Save paulcsmith/6a2d8596f985baf8bbf692973fef13d9 to your computer and use it in GitHub Desktop.
class GroupTest
include CrSerializer
property user_id : Int32 = 999
@[CrSerializer::Options(groups: ["admin"])]
property admin_id : Int32 = 123
@[CrSerializer::Options(groups: ["admin", "default"])]
property other_id : Int32 = 7777
@[CrSerializer::Options(groups: ["apiv1", "default"])]
property other_id : Int32 = 7777
@[CrSerializer::Options(groups: ["apiv1", "default"])]
property other_id : Int32 = 7777
@[CrSerializer::Options(groups: ["admin"])]
property admin_id : Int32 = 123
@[CrSerializer::Options(groups: ["admin", "default"])]
property other_id : Int32 = 7777
@[CrSerializer::Options(groups: ["apiv1", "default"])]
property other_id : Int32 = 7777
@[CrSerializer::Options(groups: ["apiv1", "default"])]
property other_id : Int32 = 7777
@[CrSerializer::Options(groups: ["admin"])]
property admin_id : Int32 = 123
@[CrSerializer::Options(groups: ["admin", "default"])]
property other_id : Int32 = 7777
@[CrSerializer::Options(groups: ["apiv1", "default"])]
property other_id : Int32 = 7777
@[CrSerializer::Options(groups: ["apiv1", "default"])]
property other_id : Int32 = 7777
end
GroupTest.new.to_json # => {"user_id":999,"other_id":7777}
GroupTest.new.to_json ["admin"] # => {"admin_id":123,"other_id":7777}
GroupTest.new.to_json ["admin", "default"] # => {"user_id":999,"admin_id":123,"other_id":7777}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment