Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
JSON::ParserError#json_path
json_path
ext/json/lib/json/common.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/ext/json/lib/json/common.rb, line 153
def json_path
return @json_path if String === @json_path
if Array === @json_path
path = build_json_path(@json_path)
@json_path = path unless frozen?
return path
end
end
Returns a best effort JSONPath string representing where in the document the parser encountered an error:
Example
begin JSON.parse('{"articles": [ { "title": invalid } ]}') rescue JSON::ParserError => error error.json_path # => "$.articles[0].title" end
See also
#build_json_path