游戏框架-如何使游戏接受“空"游戏? yaml文件中的值? [英] play framework - how can I make play accept "null" values in yaml files?
问题描述
我正在尝试从YAML文件中加载数据,其中某些字段包含空"值.当Play Framework尝试解析空"值时,将引发以下异常:
I am trying to load data from a YAML file where some fields contain "null" values. Play Framework throws the following exception when it tries to parse a "null" value:
"play.exceptions.YAMLException: null; mapping values are not allowed here".
以下是我尝试导入的数据的示例:
The following is a sample of the data I am trying to import:
person(0)
name:F1
father:
和模型:
public class Person extends Model {
public String name;
public Long father;
}
您可以从数据样本中看到父亲"字段具有空"值.父亲字段是另一个人的"ID".如何让Play接受?
You can see from the data sample that the "father" field has a "null" value. The father field is an "ID" to another person. How can I make Play accept it?
P.S:出于技术原因,我将父亲"字段的数据类型设置为长",所以请不要建议我将其设置为人"类型.
P.S: I have the "father" field as data type "Long" for technical reasons, so please don't advice me to make it a "Person" type.
推荐答案
只需将其保留在yaml文件之外. 例如,这应该可以工作
Just leave it out of the yaml file. e.g this should work
person(0)
name:F1
这篇关于游戏框架-如何使游戏接受“空"游戏? yaml文件中的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!