Skip to content

Add fromJson and toJson  #110

Closed
Closed
@sigma-andex

Description

@sigma-andex

The first thing I always need to do when using argonaut in a project is to write functions fromJson function which composes parseJson and decodeJson and toJson composing encodeJson and stringify:

fromJson :: forall t. DecodeJson t => String -> Either JsonDecodeError t
fromJson = parseJson >=> decodeJson

toJson :: forall t. EncodeJson t => t -> String
toJson = encodeJson >>> stringify

So why not add them to argonaut? They could also be named parseAndDecode/ encodeAndStringify or sth else, I don't really mind. Though I find fromJson and toJson just nicely minimalistic.

I have created a pr for it in #109 .

Update:
changed type variable from json to t in the first case to avoid confusion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions