在jaguar_serializer中运行"serializer build"时出错 [英] Error when running 'serializer build' in jaguar_serializer

查看:132
本文介绍了在jaguar_serializer中运行"serializer build"时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jaguar_serializer将json字符串转换为其相应的模型对象.我按照 https://github.com/Jaguar-dart/jaguar_serializer 中所述的步骤进行操作.但是,当我运行"serializer build"时,我总是收到此错误:

I'm trying to use jaguar_serializer to convert my json string to its corresponding model object. I followed the steps as described in https://github.com/Jaguar-dart/jaguar_serializer. However, I keep getting this error when I run 'serializer build':

'package:jaguar_generator_config/src/generator.dart':错误:第17行:非法隐式访问接收器'this' _config = loadYaml(new File(configFileName).readAsStringSync());

'package:jaguar_generator_config/src/generator.dart': error: line 17: illegal implicit access to receiver 'this' _config = loadYaml(new File(configFileName).readAsStringSync());

这是我的user.dart模型:

Here is my user.dart model:

library models.user;

import 'package:jaguar_serializer/serializer.dart';

part 'user.g.dart';

@GenSerializer()
class UserJsonSerializer extends Serializer<User> with _$UserJsonSerializer {
  User createModel() => new User();
}

/// User model
class User {
  String name;
  int age;
}

这是我的serializer.yaml文件:

And here is my serializer.yaml file:

serializers:
# Add files with your serializable class here.
- lib/models/user.dart

序列化程序的库版本为

jaguar_serializer:^ 0.3.0

jaguar_serializer: ^0.3.0

推荐答案

如果使用的是最新版本(0.3.7)

if you are using the last version (0.3.7)

serializer.yaml文件是可选的,但我们建议将其用于大型项目.

The serializer.yaml file is optional but we recommand to use it for large projects.

如有必要,请不要忘记更新软件包

Don't forget to update the package if necessary

pub global activate jaguar_serializer

如果它仍然不起作用,请尝试清理yaml文件. 删除评论并重新格式化Yaml.

if it still does not work, try to clean the yaml file a little bit. Remove the comment and reformat the yaml.

serializers:
  - lib/models/user.dart

这篇关于在jaguar_serializer中运行"serializer build"时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆