We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 142f49f commit 5660134Copy full SHA for 5660134
2 files changed
lib/rails_admin/config/fields/types/json.rb
@@ -23,6 +23,8 @@ class Json < RailsAdmin::Config::Fields::Types::Text
23
24
def parse_value(value)
25
value.present? ? JSON.parse(value) : nil
26
+ rescue JSON::ParserError
27
+ nil
28
end
29
30
def parse_input(params)
spec/rails_admin/config/fields/types/json_spec.rb
@@ -99,8 +99,8 @@
99
expect(field.parse_input(json_field: data.to_json)).to eq data
100
101
102
- it 'raise JSON::ParserError with invalid json string' do
103
- expect { field.parse_input(json_field: '{{') }.to raise_error(JSON::ParserError)
+ it 'returns nil with invalid json string' do
+ expect(field.parse_input(json_field: '{{')).to be_nil
104
105
106
0 commit comments