Skip to content
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

JSONFromString #153

Closed
OliverJAsh opened this issue Feb 9, 2021 · 0 comments
Closed

JSONFromString #153

OliverJAsh opened this issue Feb 9, 2021 · 0 comments
Assignees

Comments

@OliverJAsh
Copy link
Contributor

OliverJAsh commented Feb 9, 2021

🚀 Feature request

This package used to provide a JSONFromString type but it looks like this was removed in v0.5.0. Perhaps this was removed in favour of Either.parseJSON?

However, it would still be useful to provide a JSONFromString type in this package because it's not easy to define yourself using Either.parseJSON.

export const JSONFromString = new t.Type<E.Json, string, string>(
  'JSONFromString',
  // TODO:
  (x): x is E.Json => true,
  (s, c) =>
    pipe(
      E.parseJSON(s, (_e) => 'whatever'),
      E.fold(() => t.failure(s, c), t.success),
    ),
  JSON.stringify,
);

In order to correctly implement the is function we would need to create a Json runtime type:

Would you consider a PR that brings this back?

@gcanti gcanti self-assigned this Feb 9, 2021
gcanti added a commit that referenced this issue Feb 9, 2021
@gcanti gcanti closed this as completed in a6ed36c Feb 15, 2021
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

No branches or pull requests

2 participants