Skip to content

Distinguish between null and undefined with parse() #436

Closed Answered by eemeli
gee4vee asked this question in Q&A
Discussion options

You must be logged in to vote

With the default schema (YAML 1.2 core), an empty string and null are both representations of a null value.

If you use the parseDocument API, the parsed node's source does provide this info:

YAML.parseDocument('null').contents
Scalar {
  value: null,
  range: [ 0, 4, 4 ],
  source: 'null',
  type: 'PLAIN'
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@gee4vee
Comment options

@gee4vee
Comment options

Answer selected by gee4vee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants