I am trying to define a JSON.mapping withing a struct. I have some time fields in the record obtained from the database, which I would like to convert to millisecond timestamp when converted to JSON. I know about the awesome EpochMillisConverter. That is, the following works:
struct Rec
JSON.mapping(
mytimefield: {type: Time?, converter: EpochMillisConverter}
anothertimefield: Time?
yetanothertimefield: Time?
)
end
My question is: can I assign {type: Time?, converter: EpochMillisConverter} to a variable that I can use for all the three time fields, instead of repeating it for every time field. I tried assigning {type: Time?, converter: EpochMillisConverter} to a constant, but that does not work. I also tried property time_type = {type: Time?, converter: EpochMillisConverter}, but that also throws error saying expecting token 'CONST'.