Skip to content

Conversation

shmish111
Copy link

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

shmish111 added 2 commits May 10, 2019 13:57
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
@shmish111 shmish111 mentioned this pull request May 10, 2019
5 tasks
shmish111 added a commit to shmish111/purescript-bridge that referenced this pull request May 10, 2019
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
Copy link
Owner

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?

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?

Copy link
Author

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

Copy link
Author

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?

@Profpatsch
Copy link

Ping, anything to move this forward?

@shmish111
Copy link
Author

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.

@shmish111
Copy link
Author

closing due to #58

@shmish111 shmish111 closed this Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants