Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

json to dart

class ApiModel {
  int? userId;
  int? id;
  String? title;
  String? body;

  ApiModel({this.userId, this.id, this.title, this.body});

  ApiModel.fromJson(Map<String, dynamic> json) {
    userId = json['userId'];
    id = json['id'];
    title = json['title'];
    body = json['body'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['userId'] = this.userId;
    data['id'] = this.id;
    data['title'] = this.title;
    data['body'] = this.body;
    return data;
  }
}
Source by javiercbk.github.io #
 
PREVIOUS NEXT
Tagged: #json #dart
ADD COMMENT
Topic
Name
6+8 =