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

'BoolToStringProcessor' and 'StringToBoolProcessor' is useful to convert Uri.queryParameters to Json #171

Open
droplet-js opened this issue Mar 19, 2019 · 2 comments
Assignees

Comments

@droplet-js
Copy link
Contributor

droplet-js commented Mar 19, 2019

class BoolToStringProcessor implements FieldProcessor<bool, String> {
  const BoolToStringProcessor();

  @override
  bool deserialize(String value) {
    return value == true.toString();
  }

  @override
  String serialize(bool value) {
    return value.toString();
  }
}

class StringToBoolProcessor implements FieldProcessor<String, bool> {
  const StringToBoolProcessor();

  @override
  String deserialize(bool value) {
    return value.toString();
  }

  @override
  bool serialize(String value) {
    return value == true.toString();
  }
}

const FieldProcessor<bool, String> boolToStringProcessor =
    BoolToStringProcessor();
const FieldProcessor<String, bool> stringToBoolProcessor =
    StringToBoolProcessor();
@tejainece
Copy link
Member

That will be nice. You are welcome to send a PR for this.

Thanks!

@tejainece tejainece self-assigned this Mar 27, 2019
@droplet-js
Copy link
Contributor Author

i have send a PR#173 for this

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