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

How to get the input field data in valid json format on press of send button #10

Open
sarkaramitabh300 opened this issue Oct 28, 2020 · 1 comment

Comments

@sarkaramitabh300
Copy link

sarkaramitabh300 commented Oct 28, 2020

Currently the data I am getting in this format which is not a valid json
[{ type: Input, title: Hi Group, placeholder: Hi Group flutter, validator: digitsOnly }, { type: Password, title: Password, response: sdfag }, { type: Email, title: Email test, placeholder: hola a todos, response: agsagd }, { type: TareaText, title: TareaText test, placeholder: hola a todos, response: dvgegsdv }, { type: RadioButton, title: Radio Button tests, value: 2, list: [{ title: product 1, value: 1 }, { title: product 2, value: 2 }, { title: product 3, value: 3 }] }, { type: Switch, title: Switch test, switchValue: true }, { type: Checkbox, title: Checkbox test, list: [{ title: product 1, value: true }, { title: product 2, value: false }, { title: product 3, value: false }] }, { type: Checkbox, title: Checkbox test 2, list: [{ title: product 1, value: true }, { title: product 2, value: true }, { title: product 3, value: false }] }]

I need it in this format:

`[{
"type": "Input",
"title": "Hi Group",
"placeholder": "Hi Group flutter",
"validator": "digitsOnly"
},
{
"type": "Checkbox",
"title": "Checkbox test",
"list": [{
"title": "product 1",
"value": true
}, {
"title": "product 2",
"value": false
}, {
"title": "product 3",
"value": true

	}]
}

]`

@javierbm7
Copy link

javierbm7 commented Feb 19, 2021

Hi @AmitabhWork try with this :

final string = this.response.toString();
final newString = string.replaceAllMapped(RegExp(r'\b\w+\b'), (match) {
  return '"${match.group(0)}"';
});
print(newString);

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