[Question] Is the property omitted, or is it nullable?
gemmaro opened this issue · comments
In JSONの形式 (Version 1.0), it is explained as follows.
"?"はない場合があるという意味です
Is the property omitted, or is it nullable? That is, Does the spec allow for both, or not, where property aaa
is "?"?
{}
{ "aaa": null }
It means it's omitted like {}
, which is similar to TypeScript's ?
.
While fixing draft JSON Schema file (#51 ), following error occured to specification/files/ryuou201409020101.jkf.json
(which is symlinked from test/files/jkf/ryuou201409020101.jkf
for this constraint):
specification/files/ryuou201409020101.jkf.json invalid
[
{
instancePath: '/moves/44/move/from',
schemaPath: '#/$defs/placeFormat/type',
keyword: 'type',
params: { type: 'object' },
message: 'must be object'
}
]
where
$ jq '.moves[44].move.from' specification/files/ryuou201409020101.jkf.json
null
According to your comment above, the existing JKF files (and possibly serializer, since it seems that they are generated automatically) is against the specification, I think.
Hmm, that's a good catch. I guess I didn't really pay attention to null
vs undefined
and wrote the jkf player.
So let me update the answer: I intended to be "lacking value", but null
is acceptable if we consider the spec partially consists of jkf player too.
Options for the schema:
- Disallow
null
for thefrom
field and make these files invalid- I want to avoid this to reject possibly generated JKF files for last several years
- Allow
null
along with missing value forfrom
field (and other fields if we find ones), and note that it's a historical reason - Allow
null
for all the fields annotated with?
I'm not sure if which one of second of third is the best
In terms of JSON Schema, all options are possible 👍
Based on the current game record files, the third option seems to be a good choice. (Since the both notations has almost same semantics for humans.)
I see, makes sense. Let's go with the third option