Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

json 2 dart command line utility

a cli tool to help generate dart classes from json returned from api

important note

there is already a package called json2dart so this package will be called json2dartc !

example

this project was made using javiercbk’s json_to_dart package ! this cli was made to directly convert json stuctures into dart classes . i personally don’t like build runners and json serializers so i made this for my workflow . feel free to open issues and submit prs .

how to use

install this via pub

pub global activate json2dartc

example

json2dartc -u https://reqres.in/api/users -m get -e data -n example

null safety

to turn on null safe code generation , add the flag --null-safe , example :

json2dartc -u https://reqres.in/api/users -m get -n example --null-safe

options

-u, --api        api endpoint required to grab the json from
-e, --entry      entry point for json data structure , e.g data.data will get the nested data array/object from api response
-n, --name       name of your data class
                 (defaults to "autogenerated")
-h, --headers    headers for your api endpoint
-m, --method     method for http request , defaults to get
                 (defaults to "get")
option required default example note
-u true required field https://reqres.in/api/users
-e false data it’s used for special access in json data , e.g data.data will access nested data object within data object
-n false ‘autogenerated’ example
-h false {} access-token=01234,foo=bar
-m false get get/post

upcoming plans

  • [x] null safety support
  • [ ] tool itself written with null safety
  • [ ] private memmbers option
  • [ ] option to load json from a file

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.