Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

JSON::ResumableParser#partial_value?

partial_value? → true or false

Returns whether a document is currently under construction: an unclosed container, a key awaiting its value, etc.

It answers the same question as !partial_value.nil?, but as a cheap predicate on the parser’s internal state, without materializing the partially parsed Ruby objects:

Example
parser << '{"a":1,'
parser.parse # => false
parser.partial_value? # => true

A fully parsed document whose value hasn’t been retrieved yet is not under construction: value? returns true and partial_value? returns false.