简体   繁体   English

如何将使用graphQL的api中的响应转换为flutter中的Plain Old Dart对象?

[英]How to Convert response from api using graphQL to Plain Old Dart Object in flutter?

I am trying to convert the Json to PODO(Dart Model Class) but getting following error : 我正在尝试将Json转换为PODO(Dart模型类),但出现以下错误:

[VERBOSE-2:dart_error.cc(16)] Unhandled exception:
FormatException: Unexpected character (at character 2)

Model Class 型号类别

class FormModel {
  final String id;
  final String name;

  FormModel({this.id, this.name});

  factory FormModel.fromJSON(dynamic data) {
    return FormModel(id: data["id"], name: data["name"]);
  }
}

Creating object from JSON 从JSON创建对象

FormModel form = FormModel.fromJSON(jsonData);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 flutter_graphql 插件解析 flutter 中的 graphql 响应 - How to parse a graphql response in flutter using flutter_graphql plugin 如何处理 API 响应 model class 如果 object 在某些情况下不可用 API Flutter Dart - How to Handle API response model class if object is not Available in some situation on Same API Flutter Dart 如何在flutter/dart中将_JsonMap转换为对象 - How to convert _JsonMap to object in flutter / dart 如何在飞镖扑动中将对象转换为地图 - How to convert object to map in dart flutter 如何使用Dart / Flutter从API提取数据? - How do I fetch data from an API using dart/flutter? 如何使用 Dart 从这个 GraphQL API 获取和使用我需要的属性? - How can I get and use the properties I need from this GraphQL API using Dart? 如何从 flutter 中的 api 响应中获取数组中的 object - How to get the object from array from api response in flutter 将数据从 API 服务器转换为 Dart 和 Flutter 的 protobuf 错误 - Convert data from API server to protobuf error with Dart & Flutter 如何将 Dart 快照 object 数据从 Flutter Firestore 转换为字符串变量? - How to Convert Dart Snapshot object data to String Variables from Flutter Firestore? 从字符串中获取日期并在 Flutter Dart 中转换为日期 object - Fetch date from String and convert to Date object in Flutter Dart
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM