Module: PlatformosCheck::JsonHelpers
- Included in:
- Check, Corrector, LanguageServer::DocumentChangeCorrector
- Defined in:
- lib/platformos_check/json_helpers.rb
Instance Method Summary collapse
Instance Method Details
#format_json_parse_error(error) ⇒ Object
5 6 7 8 |
# File 'lib/platformos_check/json_helpers.rb', line 5 def format_json_parse_error(error) = error.[/\d+: (.+)$/, 1] || 'Invalid syntax' "#{message} in JSON" end |
#pretty_json(hash, start_level: 1, indent: " ") ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/platformos_check/json_helpers.rb', line 10 def pretty_json(hash, start_level: 1, indent: " ") start_indent = indent * start_level "\n \#{start_indent}\#{JSON.pretty_generate(\n hash,\n indent:,\n array_nl: \"\\n\#{start_indent}\",\n object_nl: \"\\n\#{start_indent}\"\n )}\n JSON\nend\n" |