Giter Site home page Giter Site logo

pacifio / json2dart Goto Github PK

View Code? Open in Web Editor NEW
40.0 2.0 4.0 53.6 MB

A CLI tool to help generate dart classes from json returned from API

Home Page: https://pub.dev/packages/json2dartc

License: MIT License

Dart 99.60% Shell 0.40%
dart cli code-generation json-serializer flutter flutter-tool

json2dart's Introduction

Json 2 Dart Command line utility

Important note

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

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

  • Null safety support
  • Tool itself written with null safety
  • Private memmbers option
  • Option to load json from a file

json2dart's People

Contributors

pacifio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.