{
"status": "success",
"errors": null,
"message": "Records Found successfully.",
"data": [
{
"id": 2,
"department_id": 1,
"permissions": "{"eventStatus":"1","dptStatus":"1","empStatus":"1","policyStatus":"1","openingStatus":"1","birthdayStatus":"1","hrdStatus":"1","supportStatus":"1","libraryStatus":"1","exemptionStatus":"1","settingStatus":"1","assetsStatus":"1"}"
}
]
}
How to convert this json to dart model class?
2
Answers
You either do it on your own, with
jsonDecode()
andMap
, or use thejson_serializable
package.Using
jsonDecode()
jsonDecode
:final jsonMap = jsonDecode(jsonString) as Map<String, dynamic>;
Using the
json_serializable
packageflutter pub add json_annotation dev:build_runner dev:json_serializable
build_runner
:dart run build_runner build
You can use this library to decode:
It has a method
This will decode the josnData.
You can also explore this website to make a model class.