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.
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.
Anything I can do to help shepherd this along to be merged?
There was a problem hiding this comment.
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.
@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