json_to_form icon indicating copy to clipboard operation
json_to_form copied to clipboard

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

Open sarkaramitabh300 opened this issue 4 years ago • 1 comments

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

	}]
}

]`

sarkaramitabh300 avatar Oct 28 '20 09:10 sarkaramitabh300

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);

javierbm7 avatar Feb 19 '21 03:02 javierbm7