Exception: JSON::ParserError
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Subclasses:
|
|
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
JSONError,
StandardError
|
|
|
Instance Chain:
self,
JSONError,
StandardError
|
|
| Inherits: |
JSON::JSONError
|
| Defined in: | ext/json/lib/json/common.rb |
Overview
This exception is raised if a parser error occurs.
Instance Attribute Summary
Instance Method Summary
-
#json_path
Returns a best effort JSONPath string representing where in the document the parser encountered an error:
- #build_json_path(segments) private
Instance Attribute Details
#column (readonly)
Column number where the parser encountered an error.
Is nil when raised by ResumableParser.
# File 'ext/json/lib/json/common.rb', line 151
attr_reader :column
#line (readonly)
Line number where the parser encountered an error.
Is nil when raised by ResumableParser.
# File 'ext/json/lib/json/common.rb', line 147
attr_reader :line
Instance Method Details
#build_json_path(segments) (private)
[ GitHub ]# File 'ext/json/lib/json/common.rb', line 173
def build_json_path(segments) error = false path = segments.filter_map do |segment| next if error case segment when Integer "[#{segment}]" when String, Symbol if segment.match?(/\A[a-zA-Z\$\_][a-zA-Z\$\_0-9]*\z/) ".#{segment}" else segment = segment.to_s.gsub(/["\\]/, { '"' => '\\"', '\\' => '\\\\' }) %{["#{segment}"]} end else error = true nil end end.join "$#{path}".freeze end
#json_path
# File 'ext/json/lib/json/common.rb', line 161
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