activerecord_json_validator 1.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 53b4aea1bc7007643f31d936e12b78804f96ab9f
4
- data.tar.gz: 70f49f4c9bc9930dec7cdaede3d612cd387fd00b
2
+ SHA256:
3
+ metadata.gz: a23791df42cc3761bf97c7582c7ba526806b2b163708e5bf1fe8250b6236d067
4
+ data.tar.gz: 57f080ea733883b1e83e81ed28bc28d17332b8939699a3f48cfca9ef49689ffe
5
5
  SHA512:
6
- metadata.gz: c360ce94176ec1471287f51ad23224a4cd6fe8caeee92d62df27d04df6fa518af18cd92969167282a6e6886aca46ec0221196e825db5ad8758f657165c85f4c9
7
- data.tar.gz: f1586c5cca10f3eef4dbb31d602b29f633daf2a778557642816026092db2bfc9c3ed54b672c39e9835bea877280129580d30bb55d9754a3ed47c70f6b2cac589
6
+ metadata.gz: 53836d631662e35b1e864379491a11fbebfde8207318dde0a2572f83d22811add057b5f35609f4bc267e17b0d16aa3672b8e057521ec2f797d9b160cceae0b9a
7
+ data.tar.gz: f8806eaa64ee2bb70ff2d44a91f53b8bc2c068b26eb38138f0fd600417263b138d0f5f61f35d0d08457583129260d11bcf8f54761ae4e5fd5996885988b08472
data/.rubocop.yml CHANGED
@@ -18,7 +18,7 @@ IfUnlessModifier:
18
18
  Enabled: false
19
19
 
20
20
  CaseIndentation:
21
- IndentWhenRelativeTo: case
21
+ EnforcedStyle: case
22
22
  IndentOneStep: true
23
23
 
24
24
  MethodLength:
data/.travis.yml CHANGED
@@ -1,14 +1,25 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.2
5
- - 2.1
4
+ - 2.4.6
5
+ - 2.6.3
6
6
 
7
7
  gemfile:
8
8
  - gemfiles/Gemfile.activerecord-4.2.x
9
+ - gemfiles/Gemfile.activerecord-5.0.x
10
+ - gemfiles/Gemfile.activerecord-6.0.x
11
+
12
+ matrix:
13
+ exclude:
14
+ - gemfile: gemfiles/Gemfile.activerecord-6.0.x
15
+ rvm: 2.4.6
9
16
 
10
17
  sudo: false
11
18
 
19
+ services:
20
+ - mysql
21
+ - postgresql
22
+
12
23
  env:
13
24
  - DB_ADAPTER=mysql2
14
25
  - DB_ADAPTER=postgresql
@@ -20,6 +31,3 @@ before_script:
20
31
  script:
21
32
  - 'echo "Checking code style" && bundle exec phare'
22
33
  - 'echo "Running tests" && bundle exec rake spec'
23
-
24
- addons:
25
- postgresql: 9.3
data/Gemfile CHANGED
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
  gemspec
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2015, Mirego
1
+ Copyright (c) 2013-2016, Mirego
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
data/README.md CHANGED
@@ -16,17 +16,19 @@
16
16
  Add this line to your application's Gemfile:
17
17
 
18
18
  ```ruby
19
- gem 'activerecord_json_validator'
19
+ gem 'activerecord_json_validator', '~> 2.0.0'
20
20
  ```
21
21
 
22
22
  ## Usage
23
23
 
24
24
  ### JSON Schema
25
25
 
26
+ Schemas should be a JSON file
27
+
26
28
  ```json
27
29
  {
28
30
  "type": "object",
29
- "$schema": "http://json-schema.org/draft-04/schema",
31
+ "$schema": "http://json-schema.org/draft-04/schema#",
30
32
  "properties": {
31
33
  "city": { "type": "string" },
32
34
  "country": { "type": "string" }
@@ -45,7 +47,7 @@ end
45
47
 
46
48
  class User < ActiveRecord::Base
47
49
  # Constants
48
- PROFILE_JSON_SCHEMA = Rails.root.join('config', 'schemas', 'profile.json_schema').to_s
50
+ PROFILE_JSON_SCHEMA = Pathname.new(Rails.root.join('config', 'schemas', 'profile.json'))
49
51
 
50
52
  # Validations
51
53
  validates :name, presence: true
@@ -65,16 +67,16 @@ user.profile_invalid_json # => '{invalid JSON":}'
65
67
 
66
68
  #### Options
67
69
 
68
- | Option | Description
69
- |------------|-----------------------------------------------------
70
- | `:schema` | The JSON schema to validate the data against (see **Schema** section)
71
- | `:message` | The ActiveRecord message added to the record errors (see **Message** section)
70
+ | Option | Description |
71
+ | ---------- | ------------------------------------------------------------------------------------------------------------------------------ |
72
+ | `:schema` | The JSON schema to validate the data against (see **Schema** section) |
73
+ | `:message` | The ActiveRecord message added to the record errors (see **Message** section) |
74
+ | `:options` | A `Hash` of [`json_schemer`](https://github.com/davishmcclurg/json_schemer#options)-supported options to pass to the validator |
72
75
 
73
76
  ##### Schema
74
77
 
75
- `ActiveRecord::JSONValidator` uses the `json-schema` gem to validate the JSON
76
- data against a JSON schema. You can use [any value](https://github.com/ruby-json-schema/json-schema/tree/master#usage) that
77
- `JSON::Validator.validate` would take as the `schema` argument.
78
+ `ActiveRecord::JSONValidator` uses the [json_schemer](https://github.com/davishmcclurg/json_schemer) gem to validate the JSON
79
+ data against a JSON schema.
78
80
 
79
81
  Additionally, you can use a `Symbol` or a `Proc`. Both will be executed in the
80
82
  context of the validated record (`Symbol` will be sent as a method and the
@@ -121,7 +123,7 @@ user.errors.full_messages
121
123
 
122
124
  ## License
123
125
 
124
- `ActiveRecord::JSONValidator` is © 2013-2015 [Mirego](http://www.mirego.com) and may be freely distributed under the [New BSD license](http://opensource.org/licenses/BSD-3-Clause). See the [`LICENSE.md`](https://github.com/mirego/activerecord_json_validator/blob/master/LICENSE.md) file.
126
+ `ActiveRecord::JSONValidator` is © 2013-2016 [Mirego](http://www.mirego.com) and may be freely distributed under the [New BSD license](http://opensource.org/licenses/BSD-3-Clause). See the [`LICENSE.md`](https://github.com/mirego/activerecord_json_validator/blob/master/LICENSE.md) file.
125
127
 
126
128
  The tree logo is based on [this lovely icon](http://thenounproject.com/term/tree/51004/) by [Sara Quintana](http://thenounproject.com/sara.quintana.75), from The Noun Project. Used under a [Creative Commons BY 3.0](http://creativecommons.org/licenses/by/3.0/) license.
127
129
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler'
2
4
  require 'rake'
3
5
  require 'bundler/gem_tasks'
@@ -12,7 +14,7 @@ end
12
14
 
13
15
  desc 'Start an IRB session with the gem'
14
16
  task :console do
15
- $LOAD_PATH.unshift File.expand_path('..', __FILE__)
17
+ $LOAD_PATH.unshift File.expand_path(__dir__)
16
18
  require 'activerecord_json_validator'
17
19
  require 'irb'
18
20
 
@@ -18,15 +18,15 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency 'bundler', '~> 1.3'
21
+ spec.add_development_dependency 'bundler', '~> 1.12'
22
22
  spec.add_development_dependency 'rake'
23
- spec.add_development_dependency 'rspec', '~> 3.1'
23
+ spec.add_development_dependency 'rspec', '~> 3.5'
24
24
  spec.add_development_dependency 'pg'
25
25
  spec.add_development_dependency 'mysql2'
26
- spec.add_development_dependency 'activesupport', '>= 4.1.0', '< 5'
26
+ spec.add_development_dependency 'activesupport', '>= 4.2.0', '< 7'
27
27
  spec.add_development_dependency 'phare'
28
28
  spec.add_development_dependency 'rubocop', '~> 0.28'
29
29
 
30
- spec.add_dependency 'json-schema', '~> 2.5'
31
- spec.add_dependency 'activerecord', '>= 4.2.0', '< 5'
30
+ spec.add_dependency 'json_schemer', '~> 0.2.18'
31
+ spec.add_dependency 'activerecord', '>= 4.2.0', '< 7'
32
32
  end
@@ -3,3 +3,4 @@ source 'https://rubygems.org'
3
3
  gemspec path: '../'
4
4
 
5
5
  gem 'activerecord', '~> 4.2'
6
+ gem 'pg', '~> 0.15'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '../'
4
+
5
+ gem 'activerecord', '~> 5.0'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '../'
4
+
5
+ gem 'activerecord', '~> 6.0'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class JsonValidator < ActiveModel::EachValidator
2
4
  def initialize(options)
3
5
  options.reverse_merge!(message: :invalid_json)
@@ -12,8 +14,8 @@ class JsonValidator < ActiveModel::EachValidator
12
14
 
13
15
  # Validate the JSON value with a JSON schema path or String
14
16
  def validate_each(record, attribute, value)
15
- # Validate value with JSON::Validator
16
- errors = ::JSON::Validator.fully_validate(schema(record), validatable_value(value), options.fetch(:options))
17
+ # Validate value with JSON Schemer
18
+ errors = JSONSchemer.schema(schema(record), **options.fetch(:options)).validate(value).to_a
17
19
 
18
20
  # Everything is good if we don’t have any errors and we got valid JSON value
19
21
  return if errors.empty? && record.send(:"#{attribute}_invalid_json").blank?
@@ -47,7 +49,7 @@ protected
47
49
  end
48
50
  end
49
51
 
50
- # Return a valid schema for JSON::Validator.fully_validate, recursively calling
52
+ # Return a valid schema, recursively calling
51
53
  # itself until it gets a non-Proc/non-Symbol value.
52
54
  def schema(record, schema = nil)
53
55
  schema ||= options.fetch(:schema)
@@ -59,11 +61,6 @@ protected
59
61
  end
60
62
  end
61
63
 
62
- def validatable_value(value)
63
- return value if value.is_a?(String)
64
- ::ActiveSupport::JSON.encode(value)
65
- end
66
-
67
64
  def message(errors)
68
65
  message = options.fetch(:message)
69
66
 
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
  module JSONValidator
3
- VERSION = '1.0.0'
5
+ VERSION = '2.0.1'
4
6
  end
5
7
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_record'
2
- require 'json-schema'
4
+ require 'json_schemer'
3
5
 
4
6
  require 'active_record/json_validator/version'
5
7
  require 'active_record/json_validator/validator'
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Metrics/BlockLength
1
4
  require 'spec_helper'
2
5
 
3
6
  describe JsonValidator do
@@ -39,7 +42,7 @@ describe JsonValidator do
39
42
 
40
43
  describe :validate_each do
41
44
  let(:validator) { JsonValidator.new(options) }
42
- let(:options) { { attributes: [attribute], options: { strict: true } } }
45
+ let(:options) { { attributes: [attribute], options: { format: true } } }
43
46
  let(:validate_each!) { validator.validate_each(record, attribute, value) }
44
47
 
45
48
  # Doubles
@@ -48,16 +51,18 @@ describe JsonValidator do
48
51
  let(:record_errors) { double(:errors) }
49
52
  let(:value) { double(:value) }
50
53
  let(:schema) { double(:schema) }
51
- let(:validatable_value) { double(:validatable_value) }
54
+ let(:schema_validator) { double(:schema_validator) }
55
+ let(:raw_errors) { double(:raw_errors) }
52
56
  let(:validator_errors) { double(:validator_errors) }
53
57
 
54
58
  before do
55
59
  expect(validator).to receive(:schema).with(record).and_return(schema)
56
- expect(validator).to receive(:validatable_value).with(value).and_return(validatable_value)
57
- expect(::JSON::Validator).to receive(:fully_validate).with(schema, validatable_value, options[:options]).and_return(validator_errors)
60
+ expect(JSONSchemer).to receive(:schema).with(schema, options[:options]).and_return(schema_validator)
61
+ expect(schema_validator).to receive(:validate).with(value).and_return(raw_errors)
62
+ expect(raw_errors).to receive(:to_a).and_return(validator_errors)
58
63
  end
59
64
 
60
- context 'with JSON::Validator errors' do
65
+ context 'with JSON Schemer errors' do
61
66
  before do
62
67
  expect(validator_errors).to receive(:empty?).and_return(false)
63
68
  expect(record).not_to receive(:"#{attribute}_invalid_json")
@@ -67,7 +72,7 @@ describe JsonValidator do
67
72
  specify { validate_each! }
68
73
  end
69
74
 
70
- context 'without JSON::Validator errors but with invalid JSON data' do
75
+ context 'without JSON Schemer errors but with invalid JSON data' do
71
76
  before do
72
77
  expect(validator_errors).to receive(:empty?).and_return(true)
73
78
  expect(record).to receive(:"#{attribute}_invalid_json").and_return('foo"{]')
@@ -77,7 +82,7 @@ describe JsonValidator do
77
82
  specify { validate_each! }
78
83
  end
79
84
 
80
- context 'without JSON::Validator errors and valid JSON data' do
85
+ context 'without JSON Schemer errors and valid JSON data' do
81
86
  before do
82
87
  expect(validator_errors).to receive(:empty?).and_return(true)
83
88
  expect(record).to receive(:"#{attribute}_invalid_json").and_return(nil)
@@ -93,7 +98,7 @@ describe JsonValidator do
93
98
 
94
99
  before do
95
100
  expect(validator_errors).to receive(:empty?).and_return(false)
96
- expect(validator_errors).to receive(:to_a).and_return(%i(first_error second_error))
101
+ expect(validator_errors).to receive(:to_a).and_return(%i[first_error second_error])
97
102
  expect(record).not_to receive(:"#{attribute}_invalid_json")
98
103
  expect(record_errors).to receive(:add).with(attribute, :first_error, value: value)
99
104
  expect(record_errors).to receive(:add).with(attribute, :second_error, value: value)
@@ -152,27 +157,11 @@ describe JsonValidator do
152
157
  end
153
158
  end
154
159
 
155
- describe :validatable_value do
156
- let(:validator) { JsonValidator.new(options) }
157
- let(:options) { { attributes: [:foo] } }
158
- let(:validatable_value) { validator.send(:validatable_value, value) }
159
-
160
- context 'with non-String value' do
161
- let(:value) { { foo: 'bar' } }
162
- it { expect(validatable_value).to eql('{"foo":"bar"}') }
163
- end
164
-
165
- context 'with String value' do
166
- let(:value) { "{\"foo\":\"bar\"}" }
167
- it { expect(validatable_value).to eql(value) }
168
- end
169
- end
170
-
171
160
  describe :message do
172
161
  let(:validator) { JsonValidator.new(options) }
173
162
  let(:options) { { attributes: [:foo], message: message_option } }
174
163
  let(:message) { validator.send(:message, errors) }
175
- let(:errors) { %i(first_error second_error) }
164
+ let(:errors) { %i[first_error second_error] }
176
165
 
177
166
  context 'with Symbol message' do
178
167
  let(:message_option) { :invalid_json }
@@ -181,7 +170,8 @@ describe JsonValidator do
181
170
 
182
171
  context 'with String value' do
183
172
  let(:message_option) { ->(errors) { errors } }
184
- it { expect(message).to eql(%i(first_error second_error)) }
173
+ it { expect(message).to eql(%i[first_error second_error]) }
185
174
  end
186
175
  end
187
176
  end
177
+ # rubocop:enable Metrics/BlockLength
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,6 @@
1
- $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path('lib', __dir__)
2
4
 
3
5
  require 'active_support/all'
4
6
  require 'rspec'
@@ -8,7 +10,7 @@ require 'pg'
8
10
  require 'activerecord_json_validator'
9
11
 
10
12
  # Require our macros and extensions
11
- Dir[File.expand_path('../../spec/support/macros/**/*.rb', __FILE__)].map(&method(:require))
13
+ Dir[File.expand_path('../spec/support/macros/**/*.rb', __dir__)].map(&method(:require))
12
14
 
13
15
  RSpec.configure do |config|
14
16
  # Include our macros
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class DatabaseAdapter
2
4
  def initialize(opts = {})
3
5
  @database = opts[:database]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'database_adapter'
2
4
 
3
5
  class Mysql2Adapter < DatabaseAdapter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'database_adapter'
2
4
 
3
5
  class PostgresqlAdapter < DatabaseAdapter
@@ -1,8 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DatabaseMacros
2
4
  # Run migrations in the test database
3
5
  def run_migration(&block)
6
+ migration_class = if ActiveRecord::Migration.respond_to?(:[])
7
+ ActiveRecord::Migration[4.2]
8
+ else
9
+ ActiveRecord::Migration
10
+ end
11
+
4
12
  # Create a new migration class
5
- klass = Class.new(ActiveRecord::Migration)
13
+ klass = Class.new(migration_class)
6
14
 
7
15
  # Create a new `up` that executes the argument
8
16
  klass.send(:define_method, :up) { instance_exec(&block) }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ModelMacros
2
4
  # Create a new model class
3
5
  def spawn_model(klass_name, parent_klass = ActiveRecord::Base, &block)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_json_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rémi Prévost
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-27 00:00:00.000000000 Z
11
+ date: 2021-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '1.12'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '1.12'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.1'
47
+ version: '3.5'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.1'
54
+ version: '3.5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pg
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,20 +86,20 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 4.1.0
89
+ version: 4.2.0
90
90
  - - "<"
91
91
  - !ruby/object:Gem::Version
92
- version: '5'
92
+ version: '7'
93
93
  type: :development
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - ">="
98
98
  - !ruby/object:Gem::Version
99
- version: 4.1.0
99
+ version: 4.2.0
100
100
  - - "<"
101
101
  - !ruby/object:Gem::Version
102
- version: '5'
102
+ version: '7'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: phare
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -129,19 +129,19 @@ dependencies:
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0.28'
131
131
  - !ruby/object:Gem::Dependency
132
- name: json-schema
132
+ name: json_schemer
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: '2.5'
137
+ version: 0.2.18
138
138
  type: :runtime
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: '2.5'
144
+ version: 0.2.18
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: activerecord
147
147
  requirement: !ruby/object:Gem::Requirement
@@ -151,7 +151,7 @@ dependencies:
151
151
  version: 4.2.0
152
152
  - - "<"
153
153
  - !ruby/object:Gem::Version
154
- version: '5'
154
+ version: '7'
155
155
  type: :runtime
156
156
  prerelease: false
157
157
  version_requirements: !ruby/object:Gem::Requirement
@@ -161,7 +161,7 @@ dependencies:
161
161
  version: 4.2.0
162
162
  - - "<"
163
163
  - !ruby/object:Gem::Version
164
- version: '5'
164
+ version: '7'
165
165
  description: ActiveRecord::JSONValidator makes it easy to validate JSON attributes
166
166
  with a JSON schema.
167
167
  email:
@@ -180,6 +180,8 @@ files:
180
180
  - Rakefile
181
181
  - activerecord_json_validator.gemspec
182
182
  - gemfiles/Gemfile.activerecord-4.2.x
183
+ - gemfiles/Gemfile.activerecord-5.0.x
184
+ - gemfiles/Gemfile.activerecord-6.0.x
183
185
  - lib/active_record/json_validator/validator.rb
184
186
  - lib/active_record/json_validator/version.rb
185
187
  - lib/activerecord_json_validator.rb
@@ -209,8 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
211
  - !ruby/object:Gem::Version
210
212
  version: '0'
211
213
  requirements: []
212
- rubyforge_project:
213
- rubygems_version: 2.4.5
214
+ rubygems_version: 3.1.6
214
215
  signing_key:
215
216
  specification_version: 4
216
217
  summary: ActiveRecord::JSONValidator makes it easy to validate JSON attributes with