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