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::ParserError#json_path

json_path

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