online tool for convert json to dart code
click https://m-noer.github.io/jsonToDart/
Custom dart model from https://ashamp.github.io/jsonToDartModel/
- online use, without plugin
- support null safe
- support multidimensional list
- support complex json
- support convert all props to String type
- empty props warning
- single file
- dart keyword protected
- instant convert
- object should have at least one property
- only first object in array will be parsed, empty array will cause error
- when select
Force String Type
, thebool
type will not convert
- input json string in left textinput
- input root class name in left bottom textinput
- copy code by button or mouse
json string may looks like
{
"anInt": 1,
"aDouble": 2.3,
"aString": "hello",
"aBool": false,
"anObj": {
"name": "x",
"age": 18.0
}
}
named it SomeRootEntity
and convert to dart
var obj = SomeRootEntity.fromJson(jsonDecode(json));
String encodedJson = jsonEncode(obj.toJson());
print(encodedJson);//{"anInt":1,"aDouble":2.3,"aString":"hello","aBool":false,"anObj":{"name":"x","age":18.0}}