-
Notifications
You must be signed in to change notification settings - Fork 68
option to unwrap records #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Aeson unwraps a record argument to a constructor into the JSON object see http://hackage.haskell.org/package/aeson-1.4.0.0/docs/Data-Aeson.html#t:SumEncoding "If the constructor is a record the encoded record fields will be unpacked into this object" In this commit we add an option to TaggedObject to do this unwrapping but we leave the default behaviour as is
objectFromArgs :: SumEncoding -> Maybe Foreign -> Object Foreign | ||
objectFromArgs _ Nothing = Object.empty | ||
objectFromArgs (TaggedObject { contentsFieldName, unwrapRecords }) (Just f) | ||
| typeOf f == "object" && not isArray f && unwrapRecords = unsafeFromForeign f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like it'd be better to type-case here, instead of matching on the runtime representation of the JSON. That way we know we only unwrap actual PureScript records, which arguably makes things slightly more predictable.
Does Aeson do a similar thing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything I can do to help shepherd this along to be merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for the lack of input but we will shortly be updating this a little bit I think to make sure it can be merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paf31 I'm back on this, I've added List and some small things in another branch but I want to get this merged first. I don't really understand what you mean?
Ping, anything to move this forward? |
Um, I'll have to take a look again, we have added a few things to our fork but I would like to get rid of our fork if possible. |
closing due to #58 |
Aeson unwraps a record argument to a constructor into the JSON object see
http://hackage.haskell.org/package/aeson-1.4.0.0/docs/Data-Aeson.html#t:SumEncoding
"If the constructor is a record the encoded record fields will be
unpacked into this object"
In this commit we add an option to TaggedObject to do this unwrapping
but we leave the default behaviour as is