A package for convert from json to model by http api
A package for convert from json to model by http api
flutter pub add json_parse_model -d
flutter pub add build_runner -d
host: <host>
token: <token>
example:
host: http://www.baidu.com/api
token: xxxlxlxlxlx.lxlxlxl.xlxlx.xlxlxlxlx
{
"api": "<your api path>",
"outpath": "lib/json2model_gen/<model_file_name>.dart",
"className": "<modelName>"
}
example:
{
"api": "/api/v1/healing",
"outpath": "lib/json2model_gen/healing.dart",
"className": "Healing"
}
if you add json2model.yaml
to root path. then add host: <api host address>
and token: <request authenticate token>
for http request.
run below command.
dart run build_runner build
if you don't add json2model.yaml
run below command.
dart run build_runner build -d --define json_parse_model:json=host=<api host address> --define json_parse_model:json=token=<request authenticate token>
dart pub global activate json_parse_model
if you add json2model.yaml
to root path. then add host: <api host address>
and token: <request authenticate token>
for http request.
run below command.
json build
if you don't add json2model.yaml
run below command.
json build -o <api host address> -t <request authenticate token>
if you have download the repository at locat. as command line just run below command to global command.
dart pub global activate --source path <package path>
removed command line
dart pub global deactivate json_parse_model
A package for convert from json to model by http api